[R] grep

Thomas Lumley tlumley at u.washington.edu
Thu Jan 24 18:17:26 CET 2002


On Thu, 24 Jan 2002, R. Heberto Ghezzo wrote:

> Hello, I have a problem with 'grep'
> I read several lines from a file
>  p <- readLines(pfile,n=8)
> now I have to check that a key word "JABBERWOCKY" is not in that segment
>
> a <- grep("JABBERWOCKY",p)
> which gives a 1 if the key is in the text or 'numeric(0)
> how can I test it

if (length(a))
	a is 1
else
	a is numeric(0)



	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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