[R] scan() with "what"
Ko-Kang Kevin Wang
kwan022 at stat.auckland.ac.nz
Sat Dec 14 21:45:04 CET 2002
Hi,
I have a medium-sized (19MB) CSV file that I'd like to read into R. The
read.csv() function seems to be a bit inefficient to deal with it, and I
remember that using scan() with "what" options is better.
However I'm unable to understand how to use it. The first few lines of
the data look like:
USAGE,MILEAGE,SEX,EXCESS,NCD,PRIMAGE,MINAGE,DRIVERS,DISTRICT,CARGROUP,CAR_AGE,WSCLMS,ADCLMS,FTCLMS,PDCLMS,PICLMS,ADINCUR,PDINCUR,WSINCUR,FTINCUR,PIINCUR,RECORD,DAYS,MINAGEN,PRIMAGEN
SC,7000,M,100,4,59,25,3,4,7,6,0,0,0,,,0,,0,0,,1,85,25,59
SC,7000,M,100,4,59,59,2,4,13,5,0,0,0,,,0,,0,0,,2,278,59,59
SC,7000,M,100,4,60,60,2,4,13,5,0,0,0,,,0,,0,0,,3,364,60,60
SB,10000,M,75,4,53,44,2,3,14,4,1,0,0,0,0,0,0,146.18,0,0,4,364,44,53
SB,10000,M,75,4,54,45,2,3,14,4,0,0,0,,,0,,0,0,,5,363,45,54
i.e. columns are separated by commas and may contain missing values, and
has headers.
I'd really appreciated it if someone can tell me how to use the
scan() command to read this data in.
Cheers,
Kevin
------------------------------------------------------------------------------
/* Time is the greatest teacher, unfortunately it kills its students */
Ko-Kang Kevin Wang
Master of Science (MSc) Student
Department of Statistics
University of Auckland
New Zealand
Homepage: http://www.stat.auckland.ac.nz/~kwan022
More information about the R-help
mailing list