Re: [R] how to vectorize a matrix

From: Christian Ritz <ritz_at_kvl.dk>
Date: Mon 22 May 2006 - 19:17:32 EST

Hi Lorenzo,

maybe the following example is of use?

a <- matrix(1:25,5,5)

stack(as.data.frame(a[, c(1,3,5,2,4)]))

Note that 'stack' takes a data frame or list as first argument (not a matrix). Therefore the matrix is first converted to a data frame using 'as.data.frame'.

Christian



R-help@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 Received on Mon May 22 19:29:30 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 22 May 2006 - 22:10:15 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.