[R] read file problem
Jeff Newmiller
jdnewmil at dcn.davis.ca.us
Fri Nov 3 16:37:35 CET 2006
Luis Ridao Cruz wrote:
> R-help,
>
> I have the following file I want to import to R (some lines
> removed)
>
>
> Calibrated CTD data for station:00280001
> Calibrated:23/8 2001, Salinity Unsmoothed, Fluorescence Uncalibrated
> Maximum observed depth: 36 m
> QUAL has one digit for each of pressure, temp., sal. and fluor.
> QUAL=1:Uncal., QUAL=2:OK, QUAL=6:Interp., QUAL=9:No data
>
> DEPTH CTDPRS CTDTMP CTDSAL RAWFLU NUMB. QUAL
> M DBAR IPTS-68 PSS-78 OBS.
> ******* ******* ******* *******
> 1 1.0 2999
> 2 2.0 5.9793 35.1629 .107 17 2221
> 3 3.0 5.9797 35.1631 .101 17 2221
> 4 4.0 5.9809 35.1631 .118 12 2221
> 5 5.1 5.9811 35.1629 .115 42 2221
> 6 6.1 5.9810 35.1631 .116 18 2221
> 7 7.1 5.9797 35.1631 .116 15 2221
> 8 8.1 5.9798 35.1630 .102 13 2221
> 9 9.1 5.9792 35.1629 .113 11 2221
> ...............
> ................
> .........
>
>
> If I use :
>
> read.table(file, skip = 10)
>
> it works fine but sometimes the missing data are not only
> in line number 1 ( 1 1.0 2999)
> but in lines 1,2,3,,, and therefore R fails to import the data file
>
> How can I fix it?
> I have tried with the arguments
> strip.white = TRUE
> , fill = TRUE
> , blank.lines.skip = TRUE
>
> but still not get what I want
This looks like a job for read.fwf...
?read.fwf
--
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
More information about the R-help
mailing list