Hi,

I have a question about %in% and subsettin data frames.

Say I need to keep ID 1,2,4,5, 10 from the data frame dat. I can do:

dat <- data.frame(ID = 1:10, var = 1:10)
someID <- c(1,2,4,5,10)
subset(dat, dat$ID %in% someID)

Is there a quick way to do the opposite, ie to do a subset that contains  
all ID but someID? Something like %not in%, which would *remove* lines with  
ID in someID?

I am asking because I need this in a more complex example where there are  
multiple lines with the same ID (data in long format) and I need to remove  
selected ID.

thanks,

MP

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to