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

From: William Dunlap <wdunlap_at_tibco.com>
Date: Sun, 29 May 2011 16:41:57 -0700

Try giving what an example of an integer instead of the character string "integer". E.g.,

   what = 0L
or

   what = integer(0)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

> -----Original Message-----
> From: r-help-bounces_at_r-project.org
> [mailto:r-help-bounces_at_r-project.org] On Behalf Of Matthew Keller
> Sent: Sunday, May 29, 2011 4:28 PM
> To: r help
> Subject: [R] why does scan(gzfile("file"), what='integer')
> import data as mode "character" ?
>
> 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
>
> ______________________________________________
> 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.
>



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. Received on Sun 29 May 2011 - 23:46:33 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 30 May 2011 - 00:50:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive