Using ifelse to remove unwanted rows from the dataset in R
I have a dataset where I want to remove the occurences of month 11 in the first observation year for a couple of my individuals. Is it possible to do this with ifelse? Something like: ifelse(ID=="1" & Month=="11" and Year=="2006", "remove these rows", ifelse(ID=="2" & Month=="11" & Year=="2007", "remove these rows", "nothing")) As always, all help appreciated! :) You don't even need the ifelse() if all you want is an indicator of which to remove or not. ind <- (Month == "11") & ((ID == "1" & Year == "2006") | (ID == "2" & Year == "2007")) ind will contain a TRUE if Month is "11" and if either