[R] How to stack the columns of matrix
Jonathan Baron
baron at cattell.psych.upenn.edu
Wed Jun 12 16:04:19 CEST 2002
On 06/12/02 15:36, Dr. Peter Schlattmann wrote:
>I need to stack the columns of a matrix with a variable number of columns.
>I am aware of
>
>new<-c(a[,1],a[,2])
>
>if I have a matrix 'a' with e.g. two columns. For a simulation study I
>need to stack
>the matrix with a variable number of columns. Is there a way to do this?
I'm not sure what you mean by "stack," but I think
as.vector(a)
will do what you want. It creates a vector out of a matrix,
column by column. The length of the vector will be rows x
columns of a.
--
Jonathan Baron, Professor of Psychology, University of Pennsylvania
R page: http://finzi.psych.upenn.edu/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list