[R] Large matrix into a vector
Gabor Csardi
csardi at rmki.kfki.hu
Wed Mar 28 19:33:25 CEST 2007
A matrix is just a vector with a dim attribute, so if you remove
the dim attribute it'll be a vector. The elements of a matrix
are stored columnwise so you'll get just what you want, if i get
your question right.
> g <- matrix(1:6, nc=2, nr=3)
> g
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
> dim(g) <- NULL
> g
[1] 1 2 3 4 5 6
>
Gabor
On Wed, Mar 28, 2007 at 10:27:48AM -0700, A Ezhil wrote:
> Hi,
>
> I have a matrix HR(9x27). I would like to make a
> single vector with elements: t(HR[,1]) followed by
> t(HR[,2]) and then t(HR[,3] ... etc. Is there any neat
> way of converting this matrix into a vector rather
> doing something like c(t(HR[,1]), t(HR[,2]), t(HR[,3])
> ..)?
>
> Thanks in Advance.
> Kind regards,
> Ezhil
>
>
>
> ____________________________________________________________________________________
> TV dinner still cooling?
> Check out "Tonight's Picks" on Yahoo! TV.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Csardi Gabor <csardi at rmki.kfki.hu> MTA RMKI, ELTE TTK
More information about the R-help
mailing list