Possible Duplicate:
select some values of a row in a matrix
R subset a data frame with multiple keys
Say I have a list
> test
V1 V2 V3
1 1 one uno
2 2 two duos
3 3 three tres
4 4 four cuatro
and a vector a<-c("one","three").
I want to get the subset of the list test where the element of the second column are from vector a.
So in this case answer should be something like,
V1 V2 V3
1 1 one uno
2 3 three tres
I want something on the lines of
test[test[,2]=="one",] but for multiple values. How to do that?
What you’re looking for is
%in%(although you could also usematchandsubset). See below.