[R] file input with readLines
Cable, Sam B Civ USAF AFMC AFRL/RVBXI
Sam.Cable at kirtland.af.mil
Mon Oct 3 20:26:55 CEST 2011
More on my previous question ...
I have put in timing statements to try to get a better idea of where the
problem is, like so:
conn<-file('filename','r')
for (chunk in 1:100000) {
print(paste('begin read at',date()))
Lines<-readLines(conn,n=25)
print(paste('begin processing at',date()))
# process "Lines"
print(paste('end loop at',date()))
}
Every time I go through the loop, all the date() functions return
*exactly* the same time! It *looks like* it runs through each iteration
very quickly and then takes longer and longer to simply start the next
iteration. I don't believe this. I think R must be doing some kind of
latency trick or something. But, anyway, the point is that I was
assuming the problem was in the I/O, and now I don't know if it's I/O or
processing. Either way, I don't understand it and would really
appreciate some wisdom from you guys.
Thanks.
More information about the R-help
mailing list