Re: [R] Ignoring initial rows in a text file import

2010-06-01 Thread Uwe Ligges
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 double

Re: [R] Ignoring initial rows in a text file import

2010-05-31 Thread David Winsemius
On May 31, 2010, at 9:14 PM, jim holtman wrote: This is the case where '\t' is the tab character; '\\t' would give you the backslash followed by 't' which is not what you want. Both versions "worked" in the sense of returning the number of the line with "\tBegin Main\t" > txt <- "\n\tBegi

Re: [R] Ignoring initial rows in a text file import

2010-05-31 Thread jim holtman
This is the case where '\t' is the tab character; '\\t' would give you the backslash followed by 't' which is not what you want. On Mon, May 31, 2010 at 8:19 PM, David Winsemius wrote: > > On May 31, 2010, at 8:14 PM, jim holtman wrote: > >> try this: >> >> input  <- readLines("yourfile.txt") >>

Re: [R] Ignoring initial rows in a text file import

2010-05-31 Thread David Winsemius
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. -- David. if (length(st

Re: [R] Ignoring initial rows in a text file import

2010-05-31 Thread jim holtman
try this: input <- readLines("yourfile.txt") # determine start start <- grep("\tBegin Main\t", input)[1] # first line if many if (length(start) == 1 && (start > 1)){ input <- tail(input, -(start - 1)) # delete heading lines } # find lines you want to delete breaks <- grep("\tBreak\t", input

Re: [R] Ignoring initial rows in a text file import

2010-05-31 Thread David Winsemius
On May 31, 2010, at 7:51 PM, Kevin Burnham wrote: I am trying to import a series of text files generated by stimulus presentation software. The problem that I am having is that the number of rows I need to skip is not fixed (depending on subject's pretest behavior) nor is the first row of

[R] Ignoring initial rows in a text file import

2010-05-31 Thread Kevin Burnham
I am trying to import a series of text files generated by stimulus presentation software. The problem that I am having is that the number of rows I need to skip is not fixed (depending on subject's pretest behavior) nor is the first row of the data I want always the same (the stimuli were presente