[R] problem with read.table

Pedro Rodrigues prodrigues at dcc.fc.up.pt
Mon Jul 19 10:42:46 CEST 2004


This is a strange result. I couldn't have a similar result, even with
your exact call to read.table. Maybe there is a problem with the file
(possibly some white space characters not cleaned).

If you send the first 5 lines of your text file I could say something
more.

On Mon, 2004-07-19 at 09:05, Vincent MUTEAUD wrote:
> Hello R-users,
> I apologize for my question but I'm a newbie. I want to read a file which 
> columns separator is "\t". At the end of each row there is a "\n" to go to 
> the following line. The three first lines are remarks lines and the fourth 
> contains columns titles ( variables names, ids, dates, calculated values, 
> observed values...) . I do:
> read.table("myFile", header=TRUE, sep = "\t", skip = 3)
> 
> I obtain a strange result, lines are in a bad order:
> 
>     cell6/voxel15   1998/365a       2.0     1.0     0.55 
> 0.27480000257492065     0\nRendement de la 
> culture      0.0     crop4   0/0a    0.0     1.0     0.0     0.0 
> 0\nRendement de la 
> culture      0.0     crop4   1998/75a        0.0     1.0     0.0     0.0 
>   0\nRendement de la 
> culture      0.0     crop4   1998/150a       0.0     1.0     0.0     0.0 
>   0\nRendement de la 
> culture      0.0     crop4   1998/225a       0.0     1.0     0.0     0.0 
>   0\nRendement de la 
> culture      0.0     crop4   1998/300a       0.0     1.0     0.0 
> 3.0368848       0\nRayonnement diffu 
> reçu       0.0     crop1   0/0a    0.0     2.0     0.0     0.0 
> 0\nRayonnement diffu 
> reçu       0.0     crop1   1998/50a        0.0     2.0     0.0 
> 6.8406434       0\nRayonnement diffu 
> reçu       0.0     crop1   1998/100a       0.0     2.0     0.0 
> 14.235084       0\nRayonnement diffu 
> reçu       0.0     crop1   1998/150a       0.0     2.0     0.0     14.15452 
>         0\nRayonnement diffu 
> reçu       0.0     crop1   1998/200a       0.0     2.0     0.0 
> 13.691006       0\nRayonnement diffu 
> reçu       0.0     crop1   1998/250a       0.0     2.0     0.0 
> 10.997387       0\nRayonnement diffu 
> reçu       0.0     crop1   1998/300a       0.0     2.0     0.0 
> 10.333394       0\nRayonnement diffu 
> reçu       0.0     crop1   1998/350a       0.0     2.0     0.0     4.198115 
>         0\nRayonnement diffu 
> reçu       0.0     crop9   0/0a    2.0     0.0     0.0     0.0 
> 0\nRayonnement diffu 
> reçu       0.0     crop9   1998/50a        2.0     0.0     0.0 
> 6.8406434       0\nRayonnement diffu 
> reçu       0.0     crop9   1998/100a       2.0     0.0     0.0 
> 14.235084       0\nRayonnement diffu 
> reçu       0.0     crop9   1998/150a       2.0     0.0     0.0     14.15452 
>         0\nRayonnement diffu 
> reçu       0.0     crop9   1998/200a       2.0     0.0     0.0 
> 13.676454       0\nRayonnement diffu 
> reçu       0.0     crop9   1998/250a       2.0     0.0     0.0 
> 10.983188       0\nRayonnement diffu 
> reçu       0.0     crop9   1998/300a       2.0     0.0     0.0 
> 10.333394       0\nRayonnement diffu 
> reçu       0.0     crop9   1998/350a       2.0     0.0     0.0     4.198115 
>         0\n
>    weighting            id      date   x   y    z   calculated observed
> 1         0         tree1 1998/365a 1.5 1.5 0.00 1.580000e+02  162.000
> 2         0         tree1      0/0a 1.5 1.5 0.00 6.242254e-03    0.007
> 3         0         tree1 1998/365a 1.5 1.5 0.00 1.038187e-02    0.011
> 4         0         tree1 1998/365a 1.5 1.5 0.00 1.008111e+00    0.000
> 5         0 cell4/voxel23 1998/365a 0.0 1.0 0.55 0.000000e+00    0.000
> 6         0 cell5/voxel18 1998/365a 1.0 1.0 0.25 0.000000e+00    0.000
> 7         0 cell5/voxel20 1998/365a 1.0 1.0 0.90 0.000000e+00    0.000
> 8         0 cell6/voxel15 1998/365a 2.0 1.0 0.55 0.000000e+00    0.000
> 9        NA                          NA  NA   NA           NA       NA
> 
> The "\n" is read like a word and not like a symbol to skip a line.
> What should I do?
> 
> Thanks
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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




More information about the R-help mailing list