You cannot use read.table() to read multi-line records as here. Why? It is not a table?
You can use scan() to do this. On Sat, 24 Apr 2004, CG Pettersson wrote: > 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 > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html