Reputation: 427
I have a column "Year" in my dataframe ("import") and I need to only select 2015 out of some 30 years. However none of the steps I tried worked. Things I tried include:
iy2015<-subset(import, import$year==2015)
iy2015<-import[which(import$year==2015),]
iy2015<-import[import$year==2015,]
all have given me an empty dataframe.
Upvotes: 0
Views: 71
Reputation: 3260
For me your last option works, check if 2015 is in the column and check whether year is a column name. I used: iy2015 = import[import$Year==2015,]
EDIT:
You need to use Year instead of year.
Upvotes: 1