Dear list, I have a text file from a scanner that includes 20 lines of text (scanner settings) before it actually starts showing the readings in a tabular format (headings are ID, intensity, background and few others). I am a biologist with some experience using R and my question is if it is possible to read this file into an R workspace and store the actual readings in a dataframe, avoiding the text at the begining. It seems to me that this is not the actual purpose of R, but maybe someone can point me to a method for doing this. Do I need to parse the file with some other programming language? is it possible to link, say, Perl or C++ with R to automate the reading and the analysis of such files? The aim is to be able to automate this analysis since these files are our routine experimental output. Thanks for your help, D.
Hi David! if you use read.table, there is an argument called skip. You can set that to skip=20, say. HTH, Erin On Fri, May 16, 2008 at 9:30 AM, DAVID ARTETA GARCIA <darteta001 at ikasle.ehu.es> wrote:> Dear list, > > I have a text file from a scanner that includes 20 lines of text (scanner > settings) before it actually starts showing the readings in a tabular format > (headings are ID, intensity, background and few others). > > I am a biologist with some experience using R and my question is if it is > possible to read this file into an R workspace and store the actual readings > in a dataframe, avoiding the text at the begining. It seems to me that this > is not the actual purpose of R, but maybe someone can point me to a method > for doing this. Do I need to parse the file with some other programming > language? is it possible to link, say, Perl or C++ with R to automate the > reading and the analysis of such files? The aim is to be able to automate > this analysis since these files are our routine experimental output. > > Thanks for your help, > > D. > > ______________________________________________ > 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. >-- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodgess at gmail.com
use the parameter 'skip' in read.table dat<-read.table("filename",skip=number of rows you want to skip) thanks y DAVID ARTETA GARCIA wrote:> > Dear list, > > I have a text file from a scanner that includes 20 lines of text > (scanner settings) before it actually starts showing the readings in a > tabular format (headings are ID, intensity, background and few others). > > I am a biologist with some experience using R and my question is if it > is possible to read this file into an R workspace and store the actual > readings in a dataframe, avoiding the text at the begining. It seems > to me that this is not the actual purpose of R, but maybe someone can > point me to a method for doing this. Do I need to parse the file with > some other programming language? is it possible to link, say, Perl or > C++ with R to automate the reading and the analysis of such files? The > aim is to be able to automate this analysis since these files are our > routine experimental output. > > Thanks for your help, > > D. > > ______________________________________________ > 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. > >----- Yasir H. Kaheil Catchment Research Facility The University of Western Ontario -- View this message in context: http://www.nabble.com/reading-and-analyzing-a-text-file-tp17276177p17276263.html Sent from the R help mailing list archive at Nabble.com.
This may be possible using the skip argument in read.table. It's hard to know w/o a bit more info on the structure of the text file.> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of DAVID ARTETA GARCIA > Sent: Friday, May 16, 2008 10:31 AM > To: r-help at r-project.org > Subject: [R] reading and analyzing a text file > > Dear list, > > I have a text file from a scanner that includes 20 lines of > text (scanner settings) before it actually starts showing the > readings in a tabular format (headings are ID, intensity, > background and few others). > > I am a biologist with some experience using R and my question > is if it is possible to read this file into an R workspace > and store the actual readings in a dataframe, avoiding the > text at the begining. It seems to me that this is not the > actual purpose of R, but maybe someone can point me to a > method for doing this. Do I need to parse the file with some > other programming language? is it possible to link, say, Perl or > C++ with R to automate the reading and the analysis of such files? The > aim is to be able to automate this analysis since these files > are our routine experimental output. > > Thanks for your help, > > D. > > ______________________________________________ > 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. >
1) read.table has a 'skip' argument which may suffice. 2) R has the concept of 'connections' to read sequentially through a file. See the 'R Data Import/Export' manual. If that is not enough hints, showing us an example usually intrigues people enough to offer working code. On Fri, 16 May 2008, DAVID ARTETA GARCIA wrote:> Dear list, > > I have a text file from a scanner that includes 20 lines of text (scanner > settings) before it actually starts showing the readings in a tabular format > (headings are ID, intensity, background and few others). > > I am a biologist with some experience using R and my question is if it is > possible to read this file into an R workspace and store the actual readings > in a dataframe, avoiding the text at the begining. It seems to me that this > is not the actual purpose of R, but maybe someone can point me to a method > for doing this. Do I need to parse the file with some other programming > language? is it possible to link, say, Perl or C++ with R to automate the > reading and the analysis of such files? The aim is to be able to automate > this analysis since these files are our routine experimental output. > > Thanks for your help, > > D. > > ______________________________________________ > 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.-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595