Displaying 1 result from an estimated 1 matches for "extractedvector".
2006 Jul 27
2
Vector extracted from a matrix. How can I specify dimensions in as.matrix?
...tor)
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.matrix.
as.vector does not give the wh...