[R] dropping rows

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Dec 2 01:42:33 CET 2004


Tobias Muhlhofer <t.muhlhofer at lse.ac.uk> writes:

> Hi!
> 
> 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.


myframe[myframe$year>=1960,]

or

subset(myframe, year >= 1960)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list