search for: initialmatrix

Displaying 2 results from an estimated 2 matches for "initialmatrix".

2006 Jul 27
2
Vector extracted from a matrix. How can I specify dimensions in as.matrix?
...d dim(simplevector) #3x1 matrix (vector) dim(tsimplevector)#1x3 PROBLEM: However, when the vector is extracted from a matrix, its dimension is NULL. In this case the transposed dimension is correct, but you'll see the next example, that if a row was extracted, the dimension would be wrong: initialmatrix <- matrix(1:9,3,3) extractedvector <-initialmatrix[,1] # extract first columm as vector textractedvector <-t(extractedvector)#transposed dim(extractedvector) #NULL!!!! <- not working dim(textractedvector)#1x3 as expected I have tried to transform the extracted vector as.vector and as.m...
2010 Mar 26
5
smart way to turn a vector into a matrix
Hello guys, I am working on a matrix which looks like this one: > initialMatrix <- > rbind(cbind(rep("A",3),seq(1,3)),cbind(rep("B",4),seq(1,4)),cbind(rep("C",3),seq(1,3))) > initialMatrix [,1] [,2] [1,] "A" "1" [2,] "A" "2" [3,] "A" "3" [4,] "B" "...