Skip to content
Prev 295193 / 398506 Next

all occurences of an element in a vector

To convert this from the abstract to the real ...

In what sense does %in% return only the first occurrence of an element?
See:
[1] "n" "m" "m" "n" "n"
foo        
[1,] "1" "FALSE"
[2,] "n" "TRUE" 
[3,] "m" "TRUE" 
[4,] "e" "FALSE"
[5,] "m" "TRUE" 
[6,] "n" "TRUE" 
[7,] "n" "TRUE" 
[8,] "u" "FALSE"



It sure looks to me like %in% identifies all the occurrences of
[m,n] in [1,n,m,e,m,n,n,u]

Or did you mean [m,n] appearing next to each other in that order???