Displaying 4 results from an estimated 4 matches for "bafoobar".
Did you mean:
_foobar
2005 Jun 23
3
grep negation
hi,
using the example in the grep help:
txt <- c("arm","foot","lefroo", "bafoobar")
i <- grep("foo",txt); i
[1] 2 4
but how can i get the negation (1,3) when looking for 'foo'?
thanks,
m.
1999 Oct 11
1
if(grep())
Would anyone care to comment if this is the best solution to this problem?
> trygrep <-function(x,y)
+ if(grep(x,y))
+ print("yes") else
+ print("NO")
>
>trygrep("foo","bafoobar")
[1] "yes"
>
> trygrep("foo","bar")
Error in if (grep(x, y)) print("yes") else print("NO") : missing value where
logical needed
My solution:
> trygrep <-function(x,y)
+ if(!is.na(grep(x,y)[1]))
+ print("yes") else
+ pri...
2007 Feb 16
2
if() for() { }
Dear R'helpers,
I guess the solution is trivial but despite some hours of testing and
looking at the doc, I was unable to fix the following problem.
I want to do either:
for (i in 1:lat) a[i,which(a[i,]==0] <- NA
or:
for (i in 1:lat) a[i,which(a[i,]==-9999|a[i,]==9999|a[i,]==9998|a[i,]
==-9998)] <- NA
if the word "Time" is or is not present in variable
2006 Nov 09
1
invert argument in grep
Hello,
What about an `invert` argument in grep, to return elements that are
*not* matching a regular expression :
R> grep("pink", colors(), invert = TRUE, value = TRUE)
would essentially return the same as :
R> colors() [ - grep("pink", colors()) ]
I'm attaching the files that I modified (against today's tarball) for
that purpose.
Cheers,
Romain
--