Dear R-helpers,
Does anyone know how to use regular expressions to return vector elements
that don't contain a word? For instance, if I have a vector
x - c(seal.0,seal.1-exclude)
I'd like to get back the elements which do not contain the word exclude,
using something like (I know this doesn't
Stephen Tucker wrote:
Dear R-helpers,
Does anyone know how to use regular expressions to return vector elements
that don't contain a word? For instance, if I have a vector
x - c(seal.0,seal.1-exclude)
I'd like to get back the elements which do not contain the word exclude,
using something
Find the ones that match and then remove them from the full set with 'setdiff'.
x - c(seal.0,seal.1-exclude)
x.match - grep(exclude, x) # find matches
x.match
[1] 2
setdiff(seq_along(x), x.match) # exclude the matches
[1] 1
On 4/25/07, Peter Dalgaard [EMAIL PROTECTED] wrote:
Stephen
Peter Dalgaard wrote:
Stephen Tucker wrote:
Dear R-helpers,
Does anyone know how to use regular expressions to return vector elements
that don't contain a word? For instance, if I have a vector
x - c(seal.0,seal.1-exclude)
I'd like to get back the elements which do not contain the
I use regexpr() instead of grep() in cases like this, e.g.:
x2[regexpr(exclude,x2)==-1]
(regexpr returns a vector of the same length as character vector given
it, so there's no problem with it returning a zero length vector)
-- Tony Plate
Peter Dalgaard wrote:
Stephen Tucker wrote:
Dear
Thanks guys for the suggestions guys- I come across this problem a lot but
now I have many solutions.
Thank you,
Stephen
--- Peter Dalgaard [EMAIL PROTECTED] wrote:
Peter Dalgaard wrote:
Stephen Tucker wrote:
Dear R-helpers,
Does anyone know how to use regular expressions to