How to check if a vector contains a given value?
R – Test if a vector contains a given element
rr-faqvector
Related Topic
- R – How to join (merge) data frames (inner, outer, left, right)
- Java – Why is Java Vector (and Stack) class considered obsolete or deprecated
- R – Counting the number of elements with the values of x in a vector
- R – Concatenate a vector of strings/character
- R – Grouping functions (tapply, by, aggregate) and the *apply family
- R – Drop data frame columns by name
- R – How to make a great R reproducible example
Best Answer
Both the
match()
(returns the first appearance) and%in%
(returns a Boolean) functions are designed for this.