[R] subset and "or" operator

Erich Neuwirth erich.neuwirth at univie.ac.at
Mon Mar 23 12:18:01 CET 2009


subset(table, year %in% c(1995,1998,2000))-->table2

> Hello,
> I'm trying to subset a dataframe where I have many observation taken in different years.
> I would like to subset the dataframe (in this example called "table") to get a new dataframe containing only the 
> observation of year 1995, 1998 and 2000.
> I've tried to use subset and the or operator "|" like this:
> subset(table, year==1995|1998|2000)-->table2
> but the dataframe didn't subset and I get an object called table2 that is identical to table.
> I guess I'm doing something wrong!!
> 
> Thank in advance for any suggestions!
> Laura
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 
> ------------------------------------------------------------------------
> 
> 
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.0.238 / Virus Database: 270.11.24/2018 - Release Date: 03/23/09 06:52:00
> 

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459




More information about the R-help mailing list