Weiwei Shi wrote: > Thanks. > > but I need to make it into a more general case instead of that example > > How about this?
> reshape(data.frame(df,expand.grid(id=1:10,time=1:2)), direction="wide") id x.1 y.1 z.1 x.2 y.2 z.2 1 1 -1.33527134 -0.31893666 1.1345717 0.13601140 -0.5210235 -1.6453668 2 2 -0.40199177 -0.26278190 1.5228152 0.53208796 0.5255562 0.3267309 3 3 0.05619911 0.31990391 -1.2611666 -1.15608383 0.5201109 1.5253689 4 4 1.66916616 1.08395276 0.1919081 -1.15959007 -0.1003595 2.1030876 5 5 0.11075134 -0.36423367 0.9654529 0.04113644 0.5835345 -0.7564126 6 6 -1.19880026 -1.39391323 -1.7280456 -0.24469238 0.3751702 1.1757113 7 7 -0.85106477 -0.85565217 0.7824827 -0.27263427 0.5162566 -1.8809751 8 8 -0.38502496 -0.00947673 -0.5980507 -1.52106344 -0.6601541 1.1867183 9 9 1.28152185 1.73403122 -0.1958194 -0.37358099 -2.3842039 -0.2761239 10 10 1.47900233 -0.83444107 0.5078372 1.62086099 1.9920449 -1.9054037 > On 10/29/07, Henrique Dallazuanna <[EMAIL PROTECTED]> wrote: > >> If I understand your question: >> >> df <- data.frame(x=rnorm(20), y=rnorm(20), z=rnorm(20)) >> df <- as.matrix(df) >> dim(df) >> dim(df) <- c(10,6) >> dim(df) <- c(5,12) >> >> On 29/10/2007, Weiwei Shi <[EMAIL PROTECTED]> wrote: >> >>> hi, >>> >>> if I have 20 x 3 data.frame, how to split it into >>> 10 x 6 (moving the lower part of 10x3 to column) >>> >>> or >>> >>> 5 x 12 >>> >>> thanks >>> >>> -- >>> Weiwei Shi, Ph.D >>> Research Scientist >>> GeneGO, Inc. >>> >>> "Did you always know?" >>> "No, I did not. But I believed..." >>> ---Matrix III >>> >>> ______________________________________________ >>> 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. >>> >>> >> >> -- >> Henrique Dallazuanna >> Curitiba-Paraná-Brasil >> 25° 25' 40" S 49° 16' 22" O >> > > > -- O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ 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.