I want to extract the elements of a character array that contains some particular string. For example:
x <- c('aa', 'ab', 'ac', 'bb', 'bc')
I want some function such that, given x
and 'a'
(in general this can be a string), it returns 'aa', 'ab', 'ac'
. I have experimented with a combination of %in%
, match
, which
, etc, but have not been able to make them work. Any idea?