[R] Data import, going from 8 to 550 columns
CG Pettersson
cg.pettersson at evp.slu.se
Sat Apr 24 12:47:24 CEST 2004
Hello all!
I need to import a NIR dataset into R. It should be quite trivial, but
I
can´t make it work. (No problems with the text in the beginning, as #
is
recognised by read.table as the comment sign.)
The thing I can´t get around is the <CR> that ends every line after
column eight as the line in R should be 550 columns wide (including
the JF-number).
Every new line in R should begin with the "JF2455" and so on.
Naturally it is possible to re-shape the tables in Excel before
import, but it is quite tedious and doesn´t feel right...!
How do I make read.table to just go on reading on the next line when
it comes to <CR>, and how do I make it use the double <CR> followed by
a blank to begin the next line?
The data-file(s) looks like this:
#ID=Samples from soil scanning
#SAMPLE_NUMBERS_PRESENT=Y
#NX_VARIABLES=550
#NY_VARIABLES=0
#FIRST_WAVELENGTH=1300.000000
#LAST_WAVELENGTH=2398.000000
#WAVELENGTH_INCREMENT=2.000000
JF2455 0.4367495 0.4365539 0.4363573 0.4361560 0.4359702 0.4357788
0.4355963 0.4354126 0.4352311 0.4350726 0.4349101 0.4347557 0.4346097
0.4344587
0.4343193 0.4341759 0.4340320 0.4338984 0.4337671 0.4336369 0.4335097
0.4333864
the original table is 8 columns wide, ended with a <CR>
sixty four lines removed here....
0.5015950 0.5020472 0.5026294 0.5033303 0.5041344 0.5049909 0.5059010
0.5067372
0.5075415 0.5082389 0.5089509 0.5095288 0.5101137 0.5106306 0.5111954
0.5116805
JF2456 0.3604568 0.3600681 0.3596676 0.3592694 0.3588919 0.3585098
0.3581379 0.3577725 0.3573992 0.3570563 0.3566975 0.3563588 0.3560365
0.3556931
0.3553730 0.3550543 0.3547286 0.3544230 0.3541073 0.3537982 0.3535004
0.3531921
0.3529077 0.3526271 0.3523493 0.3520919 0.3518271 0.3515673 0.3513192
0.3510693
0.3508208 0.3505693 .......
and so on
Thanks!
/CG
CG Pettersson, MSci, PhD Stud.
Swedish University of Agricultural Sciences
Dep. of Ecology and Crop Production. Box 7043
SE-750 07 Uppsala
More information about the R-help
mailing list