[R] questions about read datafile into R
Sarah Goslee
sarah.goslee at gmail.com
Mon Dec 22 21:07:10 CET 2008
This kind of problem - reading a messy data file - was discussed at
great length just last week. The ideas from that discussion may
help you with your version:
http://tolstoy.newcastle.edu.au/R/e5/help/08/12/10404.html
Sarah
On Mon, Dec 22, 2008 at 2:38 PM, Lu, Zheng <Zheng.Lu at mpi.com> wrote:
> Dear all:
>
>
>
> I have been thinking to import below one data file (.txt)into R by
> read.table(..,skip=1, header=T). But How can I deal with the repeated
> rows of TABLE NO.1 and names of data variables in the middle of this
> data file. The similar block will be repeated 100 times, here only show
> 4 of them and within each block, data records also can vary, here only
> paste 4 rows for example. I appreciate your consideration and help in
> this holiday season. Happy Holiday!
>
>
>
> TABLE NO. 1
>
> ID GID TIME OBS AMT EVID
> RATE ADDL II CMT WT IPRE
>
> 3.1000E+01 1.0000E+00 0.0000E+00 0.0000E+00 1.0000E+00 1.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 3.3918E+02
>
> 3.1000E+01 1.0000E+00 0.0000E+00 2.0500E+02 0.0000E+00 0.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 2.6267E+02
>
> 3.1000E+01 1.0000E+00 9.6000E+01 4.2100E+02 0.0000E+00 0.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 3.1781E+02
>
> TABLE NO. 1
>
> ID GID TIME OBS AMT EVID
> RATE ADDL II CMT WT IPRE
>
> 3.1000E+01 1.0000E+00 0.0000E+00 0.0000E+00 1.0000E+00 1.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 5.7557E+01
>
> 3.1000E+01 1.0000E+00 0.0000E+00 2.0500E+02 0.0000E+00 0.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 8.8583E+01
>
> 3.1000E+01 1.0000E+00 9.6000E+01 4.2100E+02 0.0000E+00 0.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 1.7342E+02
>
> 3.1000E+01 1.0000E+00 1.6800E+02 5.3100E+02 0.0000E+00 0.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 2.0179E+02
>
> TABLE NO. 1
>
> ID GID TIME OBS AMT EVID
> RATE ADDL II CMT WT IPRE
>
> 3.1000E+01 1.0000E+00 0.0000E+00 0.0000E+00 1.0000E+00 1.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 1.4389E+02
>
> 3.1000E+01 1.0000E+00 0.0000E+00 2.0500E+02 0.0000E+00 0.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 2.6147E+02
>
> 3.1000E+01 1.0000E+00 9.6000E+01 4.2100E+02 0.0000E+00 0.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 2.2634E+02
>
> 3.1000E+01 1.0000E+00 1.6800E+02 5.3100E+02 0.0000E+00 0.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 4.0733E+02
>
> TABLE NO. 1
>
> ID GID TIME OBS AMT EVID
> RATE ADDL II CMT WT IPRE
>
> 3.1000E+01 1.0000E+00 0.0000E+00 0.0000E+00 1.0000E+00 1.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 2.2003E+02
>
> 3.1000E+01 1.0000E+00 0.0000E+00 2.0500E+02 0.0000E+00 0.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 3.2116E+02
>
> 3.1000E+01 1.0000E+00 9.6000E+01 4.2100E+02 0.0000E+00 0.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 3.3642E+02
>
> 3.1000E+01 1.0000E+00 1.6800E+02 5.3100E+02 0.0000E+00 0.0000E+00
> 0.0000E+00 0.0000E+00 0.0000E+00 4.0000E+00 2.4000E-02 4.7881E+02
>
> ...
>
> ...
>
> ...
>
>
>
> zheng
>
>
>
>
>
>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list