[R] dropping rows
bates at stat.wisc.edu
Thu Dec 2 01:42:57 CET 2004
Tobias Muhlhofer wrote:
> Sorry for asking a trivial questions, but I can't seem to figure this out.
> I have a dataframe called master containing 30-odd variables.
> In this dataframe, I have observations across these 30 variables from
> 1930 to 2003 (I've made a "year" variable). How can I drop all rows for
> which the year is less than 1960? I'm assuming something with ifelse()
> but I can't quite figure it out.
> I would appreciate a suggestion of some syntax.
In R this is called subsetting and the simplest way to do this is with
the subset function.
older <- subset(master, year < 1960)
See ?subset for more variations on this theme.
More information about the R-help