a categorical variable v1 in data frame d1 can have values represented letters z. want create subset d2, excludes values, say, b, n , t. basically, want command opposite of %in%
d2 = subset(d1, v1 %in% c('b','n',t'))
you can use !
operator make true false , every false true. so:
d2 = subset(d1, !(v1 %in% c('b','n',t')))
edit: can make operator yourself:
'%!in%' <- function(x,y)!('%in%'(x,y)) c(1,3,11)%!in%1:10 [1] false false true
Comments
Post a Comment