Hi
I have data in the format below
Age V1 V2 V3 V4
23646 45190 50333 55166 56271
26174 35535 38227 37911 41184
27723 25691 25712 26144 26398
and would like to sort it as follows
Age values ind
23646 45190 V1
26174 35535 V1
27723 25691 V2
27193 30949 V2
But i have 41 columns (age column + 40 individuals)
I have the following script but an error is thrown up
can anyone help, where am i going wrong
zz <- read.csv("Filename.csv",strip.white = TRUE)
zzz <- cbind(zz[gl(nrow(zz), 1, 40*nrow(zz)), 1], stack(zz[, 2:41]))
ERROR MESSAGE
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 3789080, 0
[[alternative HTML version deleted]]
What does str(zz) tell you? -- David Winsemius On Jan 29, 2009, at 10:31 AM, Amit Patel wrote:> Hi > > I have data in the format below > > Age V1 V2 V3 V4 > 23646 45190 50333 55166 56271 > 26174 35535 38227 37911 41184 > 27723 25691 25712 26144 26398 > > and would like to sort it as follows > > Age values ind > 23646 45190 V1 > 26174 35535 V1 > 27723 25691 V2 > 27193 30949 V2 > > But i have 41 columns (age column + 40 individuals) > I have the following script but an error is thrown up > can anyone help, where am i going wrong > > zz <- read.csv("Filename.csv",strip.white = TRUE) > zzz <- cbind(zz[gl(nrow(zz), 1, 40*nrow(zz)), 1], stack(zz[, 2:41])) > > ERROR MESSAGE > Error in data.frame(..., check.names = FALSE) : > arguments imply differing number of rows: 3789080, 0 > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.
? ? ? ? ? ? ? ? ? ? ? ? 27193? ? ? 30949 ? ? ? V2> > But i have 41 columns (age column? +? 40 individuals) > I have the following script but an error is thrown up > can anyone help, where am i going wrong > > zz <- read.csv("Filename.csv",strip.white = TRUE)Try this: install.packages("reshape") library(reshape) zzz <- melt(zz) Hadley -- http://had.co.nz/