[R] How to stack the columns of matrix
Roger Bivand
Roger.Bivand at nhh.no
Wed Jun 12 15:55:58 CEST 2002
On Wed, 12 Jun 2002, Dr. Peter Schlattmann wrote:
> Dear all,
>
> 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?
>
aa <- matrix(1:25, nrow=5)
aa
as.vector(aa)
as.vector() seems to stack as you require by column.
Roger
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
and: Department of Geography and Regional Development, University of
Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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