From: jim holtman <jholtman_at_gmail.com>

Date: Mon, 31 May 2010 21:14:00 -0400

Date: Mon, 31 May 2010 21:14:00 -0400

On Mon, May 31, 2010 at 8:19 PM, David Winsemius <dwinsemius_at_comcast.net> 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.
**>
**> --
**> David.
**>
**>> 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)
**>> if (length(breaks) > 0){
**>> input <- input[-breaks]
**>> }
**>> # now read in your data
**>> real_input <- read.table(textConnection(input), header=TRUE)
**>> closeAllConnections()
**>>
**>>
**>>
**>> On Mon, May 31, 2010 at 7:51 PM, Kevin Burnham <kburnham_at_gmail.com> 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 the data I want always the same (the stimuli were
**>>> presented in random order). So I need to bring in the .txt file (using
**>>> readLines?), look for the row containing the text "Begin Main" (see exact
**>>> row below) and start reading data to a table from that point.
**>>>
**>>> [13] "Main Group\t1000\tBegin Main\tBegin Main\tBegin Main\t\t
**>>> \tPressed\t(any response)\tC\t25860\t\t\t\t\t"
**>>>
**>>> I would also like it to ignore the row:
**>>> [173] "Main Group\t1000\tBreak\tBreak\
**>>> tpause3\t\t \tPressed\t(any response)\tC\t47610\t\t\t\t\t"
**>>>
**>>> which will always be the same number of rows after the "Begin Main" row.
**>>>
**>>> Thanks,
**>>> Kevin Burnham
**>>>
**>>> [[alternative HTML version deleted]]
**>>>
**>>> ______________________________________________
**>>> R-help_at_r-project.org mailing list
**>>> https://stat.ethz.ch/mailman/listinfo/r-help
**>>> PLEASE do read the posting guide
**>>> http://www.R-project.org/posting-guide.html
**>>> and provide commented, minimal, self-contained, reproducible code.
**>>>
**>>
**>>
**>>
**>> --
**>> Jim Holtman
**>> Cincinnati, OH
**>> +1 513 646 9390
**>>
**>> What is the problem that you are trying to solve?
**>>
**>> ______________________________________________
**>> R-help_at_r-project.org mailing list
**>> https://stat.ethz.ch/mailman/listinfo/r-help
**>> PLEASE do read the posting guide
**>> http://www.R-project.org/posting-guide.html
**>> and provide commented, minimal, self-contained, reproducible code.
**>
**> David Winsemius, MD
**> West Hartford, CT
**>
**>
*

-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? ______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.Received on Tue 01 Jun 2010 - 01:16:16 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Tue 01 Jun 2010 - 02:30:25 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*