If we need to remove items in `ticker.names' that are not 'AAK.ST'.
ticker.names[!ticker.names %in% 'AAK.ST']
Or use setdiff
setdiff(ticker.names, 'AAK.ST')
Consider an approach that uses the OP,
'AAK.ST' %in% ticker.names
ticker.names['AAK.ST' %in% ticker.names]
Denying
!'AAK.ST' %in% ticker.names
ticker.names[!'AAK.ST' %in% ticker.names]
In the former case, TRUE"ticker.names" returns to the length, therefore all elements of the vector FALSEare returned , while in the latter, it receives recycling and no elements are returned.
data
ticker.names <- c('AAK.ST', 'ABB.ST', 'ALFA.ST')
akrun source
share