Hi , I have a data frame (Data1) which has a area variable (AREA) with codes (RA,RG,LT etc.). I would like to split the data frame into individual data frames called RA, RG, LT conatining only the observations from those areas. Thanks yours sincerely Andrew McCulloch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Andrew McCulloch <amcculloch at kehf.org.uk> writes:>Hi , > > I have a data frame (Data1) which has a area variable (AREA) with >codes (RA,RG,LT etc.). I would like to split the data frame into >individual data frames called RA, RG, LT conatining only the >observations from those areas.subset() might be what you want ... as in: data1.ra <- subset(data1, AREA == "RA") data1.rg <- subset(data1, AREA == "RG") data1.lt <- subset(data1, AREA == "LT") Best wishes, Mark -- Mark Myatt -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
It's simple, use the split() command. If AREA is a factor, then data2 <- split(Data1, Data1$AREA) should give you a list of dataframes split according to AREA. -roger _______________________________ UCLA Department of Statistics rpeng at stat.ucla.edu http://www.stat.ucla.edu/~rpeng On Mon, 1 Jul 2002, Andrew McCulloch wrote:> Hi , > > I have a data frame (Data1) which has a area variable (AREA) with > codes (RA,RG,LT etc.). I would like to split the data frame into > individual data frames called RA, RG, LT conatining only the > observations from those areas. > > Thanks > > yours sincerely > Andrew McCulloch > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._