search for: resultmatrix

Displaying 4 results from an estimated 4 matches for "resultmatrix".

2006 Aug 19
2
A matrix problem
...this, > MATRIX [,1] [,2] [1,] 1 3 [2,] 5 1 [3,] 2 1 [4,] 1 5 I'd like to get as a result vector the sums of these indexes, something like this: > c(8,1,0,0,1) How to do this? I did solved it this way, but is there some more elegant way: RESULTVECTOR=c(); RESULTMATRIX=c(); INDEXES=as.integer(names(table(TRANSP_TABLE[,1]))); for(i in INDEXES) { RESULTVECTOR=c(i,sum(MATRIX[,2][MATRIX[,1]==i])) RESULTMATRIX=rbind(RESULTMATRIX,RESULTVECTOR) } row.names(RESULTMATRIX)<-INDEXES; RESULTMATRIX=RESULTMATRIX[,2]; > RESULTMATRIX 1 2 5 8 1 1 Atte Tenkanen Unive...
2006 Oct 17
1
looking for a cleaner way to do something
...vided by the respective first element in each vector. ( so 52, 63 and 85 should all get divided by 1417 and 41, 50 and 97 should all be divided by 1213 ). it doesn't have to retain the column names because i can just assign them again when i am assigning the rownames. below is my code : resultmatrix<-rbind(temp1,temp2) resultmatrix<-resultmatrix[,2:17]/resultmatrix[,1] colnames(resultmatrix)<-colnames(temp1) rownames(resultmatrix)<-c("group1","group2") I'm pretty sure above will work but it seemed kind of ugly and I wondering if there is a better way bec...
2007 Mar 03
1
function doesnt return/create object
hello, i have written a function to extract certain lines from a matrix. the result is a matrix with 6 cols, named dynamically according to the functions arguments. the problem is now, that i'm not able to return the resultmatrix for further use. the object is not being created. example from my console: getans(27,27) [...] [189,] 3969 161 27 1 0 1 [190,] 2142 87 27 1 0 1 [191,] 1318 52 27 1 0 1 [192,] 2881 120 27 1 0 1 [193,] 3669 152 27 1 0 1 [194,] 5653 22...
2007 Mar 03
1
apply ? function doesnt create object
hello, i have written a function to extract certain lines from a matrix. the result is a matrix with 6 cols, named dynamically according to the functions arguments. the problem is now, that i'm not able to return the resultmatrix for further use. the object is not being created. example from my console: getans(27,27) [...] [189,] 3969 161 27 1 0 1 [190,] 2142 87 27 1 0 1 [191,] 1318 52 27 1 0 1 [192,] 2881 120 27 1 0 1 [193,] 3669 152 27 1 0 1 [194,] 5653 22...