Skip to content

subset and "or" operator

2 messages · lauramorgana at bluewin.ch, Erich Neuwirth

#
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
#
subset(table, year %in% c(1995,1998,2000))-->table2