[R] why does scan(gzfile("file"), what='integer') import data as mode "character" ?

Matthew Keller mckellercran at gmail.com
Mon May 30 01:28:14 CEST 2011


Hi all,

My code:

x <- scan(gzfile("file"),what='integer')

x is imported, but as mode "character" rather than "integer". I know I
can do as.integer() when importing, but am still trying to figure out
why the above occurs. When I do
summary(as.integer(x)), there are no NAs introduced by coercion, so
the vector really is all integer.

Also, is the above code the fastest for importing a very long zipped
data, with 132 million rows and 1 column?

Thanks in advance,

Matt


-- 
Matthew C Keller
Asst. Professor of Psychology
University of Colorado at Boulder
www.matthewckeller.com



More information about the R-help mailing list