Test if a vector contains a given element
Both the match() (returns the first appearance) and %in% (returns a Boolean) functions are designed for this. v <- c(‘a’,’b’,’c’,’e’) ‘b’ %in% v ## returns TRUE match(‘b’,v) ## returns the first location of ‘b’, in this case: 2