[R] Ignoring initial rows in a text file import

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Jun 1 18:33:29 CEST 2010



On 01.06.2010 02:19, David Winsemius wrote:
>
> On May 31, 2010, at 8:14 PM, jim holtman wrote:
>
>> try this:
>>
>> input <- readLines("yourfile.txt")
>> # determine start
>> start <- grep("\tBegin Main\t", input)[1] # first line if many
>
> Puzzled. I thought backslashes in grepping patterns needed to be
> doubled? I guess not.
>


Well, yes, for a backslash, but here a tab is specified, but no 
backslash at all.

Additionally, see ?regex:
"The current implementation interprets \a as BEL, \e as ESC, \f as FF, 
\n as LF, \r as CR and \t as TAB."

Uwe Ligges



More information about the R-help mailing list