[R] how to locate specific line?

Jinsong Zhao j@zh@o @ending from ye@h@net
Fri Jul 27 10:13:04 CEST 2018

Hi there,

I have a large/huge text file. I need to locate a line in the file with 
a specific string, for example, "Data Points". Now, I use the following 
code to do:

df <- readLines(file)
l <- grep("Data Points", df)

However, in this case, the file will be read throughout into R. When the 
file is huge, it will cost much memory and time.

Is there any more elegant way to do that? Thanks.


More information about the R-help mailing list