[R] Re shape matrix from wide to long format
dieter.menne at menne-biomed.de
Tue Nov 25 14:09:09 CET 2008
Daren Tan wrote:
> I forgot the reshape equivalent for converting from wide to long format.
> Can someone help as my matrix is very big. The following is just an
>> m <- matrix(1:20, nrow=4, dimnames=list(LETTERS[1:4], letters[1:5]))
Gabor's solution is uses more basic functions, but package reshape or
function reshape(...direction="long") would also work
m <- matrix(1:20, nrow=4, dimnames=list(LETTERS[1:4], letters[1:5]))
mdf = cbind(V1=rownames(m),as.data.frame(m))
View this message in context: http://www.nabble.com/Reshape-matrix-from-wide-to-long-format-tp20680567p20680900.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help