Well, I am not sure if Tail
and Class
are part of the same dataframe or are two seperate vectors. If they are two seperate vectors, maybe you can merge the two vectors in a dataframe
df <- data.frame(Tail = as.character(Tail), Class = as.character(Class))
and then with dplyr
you can try,
library(dplyr)
df %>%
group_by(Tail) %>%
summarise(uniq=n_distinct(Class)) %>%
filter(uniq ==2)
# Tail uniq
# (fctr) (int)
#1 B-123 2
#2 B-888 2
2
solved Subsetting multiple vectors based on a specific condition