Reputation: 583
I make a vector V of length 9 from a matrix A or order 3*3 using its elements row wise. The code i tried.
A<-matrix(1:9,3,3)
V<-c(A[1,],A[2,],A[,3])
But I want to generalized it using loop.
Upvotes: 0
Views: 94
Reputation: 206167
How about
as.vector(t(A))
just transpose the matrix and convert to vector. Simple.
Upvotes: 1