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
> example.
>
>> 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
library(reshape)
m <- matrix(1:20, nrow=4, dimnames=list(LETTERS[1:4], letters[1:5]))
mdf = cbind(V1=rownames(m),as.data.frame(m))
melt(mdf)
Dieter
--
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.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.