[R] Reading comments in text file from R
Coen van Hasselt
coenvanhasselt at gmail.com
Wed Dec 2 19:34:16 CET 2009
Try readLines, for instance:
# test.txt contents
comments
a,b,c
1,1,1
2,2,2
> readLines("c:/test.txt",1)
[1] "comments"
> read.csv("c:/test.txt",skip=1)
a b c
1 1 1 1
2 2 2 2
Coen
On Wed, Dec 2, 2009 at 19:26, Graham Smith <myotisone at gmail.com> wrote:
> When a text file starts with a few lines commented out with # can you
> read those line from within R.
>
> read.table ignores the comments to load the file, but it would
> sometimes be useful to be able to read what these comments say.
>
> Thanks,
>
> Graham
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list