Hello to all is there a function wich splits a data.frame (column1,column2,column3,....) into data1 <-(column1,column3....) #column2 = 1 data2 <-(column1,column3....) #column2 = 2 data3 <-(column1,column3....) #column2 = 3 ... Regards Knut
Dimitris Rizopoulos
2008-Feb-26 10:34 UTC
[R] Split data.frames depeding values of a column
try split(), e.g., dat <- data.frame(x = rnorm(12), y = runif(12), z = rep(1:4, 3)) dat split(dat[1:2], dat$z) I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Knut Krueger" <rh at family-krueger.com> To: "'R R-help'" <r-help at stat.math.ethz.ch> Sent: Tuesday, February 26, 2008 11:22 AM Subject: [R] Split data.frames depeding values of a column> Hello to all > is there a function wich splits a data.frame > (column1,column2,column3,....) > > into > data1 <-(column1,column3....) #column2 = 1 > data2 <-(column1,column3....) #column2 = 2 > data3 <-(column1,column3....) #column2 = 3 > ... > Regards Knut > > ______________________________________________ > 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. >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
Seemingly Similar Threads
- R Shiny Help - Trouble passing user input columns to emmeans after ANOVA analysis
- Function to read a string as the variables as opposed to taking the string name as the variable
- New Variable from Several Existing Variables
- Displaying median value over the horizontal(median)line in the boxplot
- Reading sections of data files based on pattern matching