Re: [R] Reading multiple tables from one .txt doc

2016-05-04 Thread Loris Bennett
Mark Fingerle writes: > Dear all, > I have a .txt file which contains multiple tables and I would like to > read these tables separately in order to create graphs for each one. > The tables are separated by a blank line, have a variable number of > lines, fixed nr. Of rows, have a header and a c

Re: [R] Reading multiple tables from one .txt doc

2016-05-03 Thread William Dunlap via R-help
The following base R code does roughly what Bert suggests. It does no checking that the data is in the format you describe. The split-by-cumsum trick is a handy idiom. # lines <- readLines(yourFile), or, for this example: lines <- c("#One","X Y Z","1 2 3","4 5 6","", "#Two", "X Y

Re: [R] Reading multiple tables from one .txt doc

2016-05-03 Thread Bert Gunter
One approach would be to use ?readLines to read the lines into a character vector. You could then use indexing to remove all the blank and header (lines beginning with "image") lines. You can now find the indices of where the separate data blocks begin (they all begin with "#", right?) and then seq

[R] Reading multiple tables from one .txt doc

2016-05-03 Thread Mark Fingerle
Dear all, I have a .txt file which contains multiple tables and I would like to read these tables separately in order to create graphs for each one. The tables are separated by a blank line, have a variable number of lines, fixed nr. Of rows, have a header and a comment above the header (#) which