[R] Newbie: Subsets of data frame

kjetil halvorsen kjetilh at umsanet.edu.bo
Tue Sep 24 02:08:32 CEST 2002


What about 

milk[milk$location =="Alta"]


Kjetil Halvorsen

John Deke wrote:
> 
> Could you give some details on what commands you tried, what you hoped they
> would do, and how they failed?
> 
> -----Original Message-----
> From: owner-r-help at stat.math.ethz.ch
> [mailto:owner-r-help at stat.math.ethz.ch]On Behalf Of Morten Sickel
> Sent: Monday, September 23, 2002 10:59 AM
> To: 'r-help'
> Subject: [R] Newbie: Subsets of data frame
> 
> I feel a bit embarassed by this, but I have not managed to find out how:
> 
> I have a data frame containing measurements over time for a number of
> different locations:
> 
> > str(milk)
> `data.frame':   845 obs. of  3 variables:
>  $ date    : num  1987 1987 1987 1987 1987 ...
>  $ value   : num  5 1 2 5 1 1 2 3 2 4 ...
>  $ location: Factor w/ 36 levels "Alta","Andoy",..: 1 1 1 1 1 1 1 1 1 1 ...
> 
> I assume there is some simpe way of extracting subsets of the data frame for
> analysing the time series for just one of the location, but how? I have
> tried using various variants of extract, [] and subset, but obiously, I have
> missed something, for I have not managed to get out what I want.
> 
> --
> Morten Sickel
> Norwegian Radiation Protection Authority
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
> -.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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