Re: [R] Read every second line from ASCII file

2007-05-02 Thread Roland Rau
Dear all, I just realized that I forgotten to write some kind of final email for this thread and to thank you for your help. It seems that the recommeneded procedure in such circumstances has three steps: 1) readLines() 2) select the desired lines 3) strsplit() Thanks Ferdinand, Jim, and Paul!

Re: [R] Read every second line from ASCII file

2007-05-02 Thread Gabor Grothendieck
I typically wouldn't use strsplit but would reread it using read.table and textConnection as in: http://www.mail-archive.com/r-help@stat.math.ethz.ch/msg84752.html On 5/2/07, Roland Rau [EMAIL PROTECTED] wrote: Dear all, I just realized that I forgotten to write some kind of final email for

[R] Read every second line from ASCII file

2007-04-30 Thread Roland Rau
Dear all, I have an ASCII file where records are separated by a blank. I would like to read those data; however, only the data in rows 1, 3, 5, 7, ... are important; the other lines (2,4,6,8,) contain no useful information for me. So far I used awk/gawk to do it: gawk '{if ((FNR % 2) != 0)

Re: [R] Read every second line from ASCII file

2007-04-30 Thread Ferdinand Alimadhi
Hi, You can start by reading all lines from your file: lines - readLines(pathtoyourfile) then keep only odd lines: oddlines - lines[seq (1, length(lines),2)] You have to split the line into fields, e.g res - strsplit(oddlines, split = \t) if you have tab as field seperator hth On

Re: [R] Read every second line from ASCII file

2007-04-30 Thread jim holtman
Use readLines and then just use the odd numbered lines: x.in - readLines(yourFile) x.in - x.in[seq(1, length(x.in), 2)] # every 2nd line or just to make sure, only delete blank lines: x.in - x.in[!(x.in == )] On 4/30/07, Roland Rau [EMAIL PROTECTED] wrote: Dear all, I have an ASCII file