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
On Dec 2, 2009, at 1:26 PM, Graham Smith wrote:> When a text file starts with a few lines commented out with # can you > read those line from within R.?readLines> > 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.David Winsemius, MD Heritage Laboratories West Hartford, CT
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. >