[R] if(grep())
Thomas Lumley
thomas at biostat.washington.edu
Tue Oct 12 00:27:51 CEST 1999
On Tue, 12 Oct 1999, Michael Lapsley wrote:
> 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
You could try
if(length(grep(x,y))==0)
Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list