[R] Search within a file
Gabor Grothendieck
ggrothendieck at gmail.com
Thu Nov 3 16:15:47 CET 2005
Would this be ok (on Windows, use grep on UNIX):
# line numbers of all lines conitaining R in the R README file
setwd(R.home())
as.numeric(sub(":.*", "", system("findstr /n R README", intern = TRUE)))
On 11/3/05, Tuszynski, Jaroslaw W. <JAROSLAW.W.TUSZYNSKI at saic.com> wrote:
> Hi,
>
> I am looking for a way to search a file for position of some expression,
> from within R. My current code:
>
> sha1Pos = gregexpr("<sha1>", readChar(filename,
> file.info(filename)$size))[[1]]
>
> Works fine for small files, but text files I will be working with might get
> up to Gb range, so I was trying to accomplish the same without loading the
> whole file into R.
>
> I realize this is not what R is designed to do, but maybe there is some way
> I am missing.
>
> Jarek Tuszynski
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
More information about the R-help
mailing list