i have 2 variables, both factor objects, var1 has 3600 observations, var 2 has 9000 observations, want var3 has observations var2 found in var1.
maybe title misleading couldn't come else.
your question benefit example data, assuming i've interpreted correctly, might looking following:
var1 <- as.factor(c("a", "b", "a", "a", "a", "a")) var2 <- as.factor(c("a", "b", "a", "c", "a", "d", "a", "k", "a")) var3 <- var2[var2 %in% var1] var3 # > var3 # [1] b a a # levels: b c d k
Comments
Post a Comment