[R] split a data frame

Mark Myatt mark at myatt.demon.co.uk
Mon Jul 1 16:47:15 CEST 2002


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



More information about the R-help mailing list