Skip to content
Prev 334226 / 398506 Next

Splitting a vector

You don't need to wrap 1:12 in c().

 Since matrices are just folded vectors, you can convert vector X to a matrix Xm:

Xm <- matrix( X, nrow=3 )

and access columns to get your your sub-vectors:

Xm[,1]
Xm[,2]

and so on.

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Long Vo <long_vo_hai at yahoo.com.vn> wrote: