Hello again,

How do I split a data frame into smaller, completely separate data frames 
(rather than separate data frames comprising a single "list")? Consider the 
following data, and my coding attempt:

x <- read.table(textConnection("id type number
indv.1 bagel 6
indv.2 bagel 1
indv.3 donuts 10
indv.4 donuts 9"), header = TRUE)
closeAllConnections()

x.split <- split(x, x$type)

This is where I'm stuck. Now I have one "list" comprised of different data 
frames, but what I want is separate data frames.

Ideally, I'd like to design a loop to give sequentially-numbered names to the 
separate data frames I create. This is because my real data will have many more 
than two groups (i.e., many more types of things than just "bagels" versus 
"donuts") and the number of groups will vary when I apply the same code to 
different data sets.

Many thanks in advance for your replies!
-----------------------------------
Josh Banta, Ph.D
Center for Genomics and Systems Biology
New York University
100 Washington Square East
New York, NY 10003
Tel: (212) 998-8465
http://plantevolutionaryecology.org



      
        [[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.

Reply via email to