[R] How do I read multiple rows of different lengths?
smcguffee
sean.mcguffee at gmail.com
Wed Oct 27 22:13:38 CEST 2010
Using the text itself works, although slightly annoying. I ended up just
processing the text each time I wanted a value inside it, which turns out to
be about the same thing. The key to processing the text ended up being a
command: library("CGIwithR") followed by another command scanText(textLine)
to process each text line. Below is an example where if I change n, I can
look at any section of data. It bewilders me as to why R doesn't come with
scanText without loading some sort of library automatically loaded, but hey,
this eventually worked for me and it only took about a full day to figure it
out. I don't know of any other software that could do the same task without
the same effort in figuring out how to do it. Plus, R is free and whatnot,
so I think it is turning out to be worth the headache of easy things not
being obvious.
fitLines=readLines("testOut")
n=1
x=as.numeric(scanText(fitLines[(n-1)*6+2])[2:length(scanText(fitLines[(n-1)*6+2]))])
y=as.numeric(scanText(fitLines[(n-1)*6+3])[2:length(scanText(fitLines[(n-1)*6+3]))])
fit=as.numeric(scanText(fitLines[(n-1)*6+4])[2:length(scanText(fitLines[(n-1)*6+4]))])
res=as.numeric(scanText(fitLines[(n-1)*6+5])[2:length(scanText(fitLines[(n-1)*6+5]))])
plot(x,y)
lines(x,fit)
legend(x[1],max(y),legend=c(scanText(fitLines[(n-1)*6+6])))
--
View this message in context: http://r.789695.n4.nabble.com/How-do-I-read-multiple-rows-of-different-lengths-tp3015986p3016219.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list