If you execute the same script several times and the data file does not
change, it may be a good idea to save it as an R object:

if (file.access('mydata.obj',0)==0) {
              load('mydata.obj')
} else {
             a<-read.table("mydata.csv,...)
             save(a,file='mydata.obj')
}

It can speed up things considerably.

Christophe Pallier


On 5/15/07, Liaw, Andy <andy_liaw@merck.com> wrote:
>
> If it's a matrix, use scan().  If the columns are not all the same type,
> use the colClasses argument to read.table() to specify their types,
> instead of leaving it to R to guess.  That will speed things up quite a
> lot.
>
> Andy
>
> From: Lorenzo Isella
> >
> > Dear All,
> > Hope I am not bumping into a FAQ, but so far my online search
> > has been fruitless
> > I need to read some data file using R. I am using the (I think)
> > standard command:
> >
> > data_150<-read.table("y_complete06000", header=FALSE)
> >
> > where y_complete06000 is a 6000 by 40 table of numbers.
> > I am puzzled at the fact that R is taking several minutes to
> > read this file.
> > First I thought it may have been due to its shape, but even
> > re-expressing and saving the matrix as a 1D array does not help.
> > It is not a small file, but not even huge (it amounts to about 5Mb of
> > text file).
> > Is there anything I can do to speed up the file reading?
> > Many thanks
> >
> > Lorenzo
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch 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.
> >
> >
> >
>
>
>
> ------------------------------------------------------------------------------
> Notice:  This e-mail message, together with any attachments,...{{dropped}}
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>



-- 
Christophe Pallier (http://www.pallier.org)

	[[alternative HTML version deleted]]

