[R] grep in filename

Alberto Monteiro albmont at centroin.com.br
Thu Oct 4 19:50:08 CEST 2007


Is there any version of grep that gets information from the filename?

For example:
x <- "myfile.txt"
y <- grep.file("my text", x)
should return in y the lines with my text.

I know that
x <- "myfile.txt"
y <- grep("my text", readLines(x))
will probably work, but maybe there's a more direct (and
less memory hungry) option.

Alberto Monteiro



More information about the R-help mailing list