[R] How to override coerion error in 'scan'

From: Kittler, Richard <richard.kittler_at_amd.com>
Date: Sat 23 Apr 2005 - 12:17:48 EST

I am using 'read.csv' in V2.0.1 to read in a CSV file with the colClasses option and am getting an error from 'scan' when it encounters a non-numeric value for a 'numeric' column, i.e.

> ds <- read.csv(in_file, nrows=irow, row.names=NULL,


  Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :

     "scan" expected a real, got "03/15/200523:56:03"

Is there a way to override this and just have it convert those values to NA? The dataset is large so I would prefer not to have to import the columns as character and convert them to numeric afterward.


Richard Kittler

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 Received on Sat Apr 23 12:23:39 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:22 EST