Dear List, I have, say, a 2000x1 numeric vector and would like to split it into, say, a 200x10 matrix. Any help is appreciated.
How to split a single vector into a multiple-column and multiple-row matrix
3 messages · R_xprt_wannabe, Roger D. Peng, Dimitris Rizopoulos
You can use 'matrix()', as in x <- 1:2000 matrix(x, nrow = 200, ncol = 10) -roger
R_xprt_wannabe wrote:
Dear List, I have, say, a 2000x1 numeric vector and would like to split it into, say, a 200x10 matrix. Any help is appreciated.
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Roger D. Peng http://www.biostat.jhsph.edu/~rpeng/
x <- rnorm(2000) dim(x) <- c(200, 10) ## or if you want it by row: matrix(x, 200, 10, TRUE) Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm ----- Original Message ----- From: "R_xprt_wannabe" <r_xprt_wannabe at yahoo.com> To: <r-help at stat.math.ethz.ch> Sent: Friday, March 25, 2005 4:12 PM Subject: [R] How to split a single vector into a multiple-column andmultiple-row matrix
Dear List, I have, say, a 2000x1 numeric vector and would like to split it into, say, a 200x10 matrix. Any help is appreciated.
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html