Gustaf Rydevik
2009-Jan-14 11:51 UTC
[R] reshape, direction=long: "multiple row names not allowed"
Hi all, for some reason I always get stuck spending hours when trying to use reshape or the Reshape package. Heaven knows why. My latest frustration (in 2.7.1, so ignore if this has been fixed): test<-data.frame(matrix(rnorm(42*4),ncol=4),rep(1:21,2),rep(c("a","b"),each=21)) reshape(test,varying=list(colnames(test)[1:4]),direction="long") test<-data.frame(matrix(rnorm(42*4),ncol=4),id=rep(1:21,2),rep(c("a","b"),each=21)) reshape(test,varying=list(colnames(test)[1:4]),direction="long") The first works, but the second does not. The only information on why is that "duplicate row names are not allowed". It took me a fair time before figuring out that it was the "id"-column that caused problems. Perhaps something to fix, or at least give a more informative error message? Best regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik
hadley wickham
2009-Jan-14 14:07 UTC
[R] reshape, direction=long: "multiple row names not allowed"
On Wed, Jan 14, 2009 at 5:51 AM, Gustaf Rydevik <gustaf.rydevik at gmail.com> wrote:> Hi all, > > for some reason I always get stuck spending hours when trying to use > reshape or the Reshape package. Heaven knows why. > My latest frustration (in 2.7.1, so ignore if this has been fixed): > > test<-data.frame(matrix(rnorm(42*4),ncol=4),rep(1:21,2),rep(c("a","b"),each=21)) > reshape(test,varying=list(colnames(test)[1:4]),direction="long") > > test<-data.frame(matrix(rnorm(42*4),ncol=4),id=rep(1:21,2),rep(c("a","b"),each=21)) > reshape(test,varying=list(colnames(test)[1:4]),direction="long") > > The first works, but the second does not. The only information on why > is that "duplicate row names are not allowed". > It took me a fair time before figuring out that it was the "id"-column > that caused problems. > Perhaps something to fix, or at least give a more informative error message?Well there isn't any problem with the reshape package: test <- data.frame( matrix(rnorm(42 * 4), ncol = 4), A = rep(1:21,2), B = rep(c("a","b"), each = 21) ) library(reshape) melt(test, id = c("A", "B")) but I'm not sure what you're trying to achieve. Hadley PS. Usingwhitespacemakesyourcodeeasiertoread! -- http://had.co.nz/
Seemingly Similar Threads
- New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())
- New errors with difftime()-objects in 2.11.1 (was Re: Request: difftime method for cut())
- download.file not working
- Change the position of panel strips in a lattice plot.
- two-sample test of multinomial proportion