Skip to content
Prev 244764 / 398502 Next

How to ignore data

Steve Sidney <sbsidney <at> mweb.co.za> writes:
It would help to have a more precise/reproducible example, but if
your data set (a data frame) is d, and you want to ignore cases where
the response variable x is either 0 or 1, you could say

  ds <- subset(d,!x %in% c(0,1))

Some modeling functions (such as lm()), but not all of them, have
a 'subset' argument so you can provide this criterion on the fly:

 lm(...,subset=(!x %in% c(0,1)))