Perhaps:
SplitByRow <- function(data, rows){ coln <- colnames(data) df <- as.matrix(data) dim(df) <- c(dim(df)[1]/rows, dim(df)[2]*rows) colnames(df) <- rep(coln, rows) return(df) } SplitByRow(df, 2) On 29/10/2007, Weiwei Shi <[EMAIL PROTECTED]> wrote: > > Thanks. > > but I need to make it into a more general case instead of that example > > > > 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 > > > -- > Weiwei Shi, Ph.D > Research Scientist > GeneGO, Inc. > > "Did you always know?" > "No, I did not. But I believed..." > ---Matrix III > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ 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.