[R] Can I improve the efficiency of my scan() command?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sat Apr 12 09:14:17 CEST 2003
On Sat, 12 Apr 2003, Ko-Kang Kevin Wang wrote:
[...]
> For example, the CSV file has 25 columns but I don't need 3 of them (6, 7,
> and 22). What I have done is to scan them in anyway, convert the list
> into a data frame then remove the 3 columns. Just wonder if it is
> possible to simply ignore them in scan() to make the process faster?
Yes: see the help page
If any of the types is `NULL', the corresponding field is skipped
(but a `NULL' component appears in the result).
If you don't need a data frame, don't do the conversion. You might
well find read.table setting colClasses is faster than converting by
as.data.frame.
--
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
More information about the R-help
mailing list