[R] Error: not 'a real'?

Brian zenlines at gmail.com
Sat Oct 20 14:25:42 CEST 2012


Hi Jim,

On 10/20/12 13:36, Jim Holtman wrote:
> how about supplying the context  of the error. Show the lines in the file where the error occurred.
 >
 > Sent from my iPad
 >
 > On Oct 20, 2012, at 7:21, Brian <zenlines at gmail.com> wrote:
 >
 >> Hi List,
 >>
 >> when supplying a vector of atomic vector classes to read.table, I get:
 >> # column classes
 >> colClasses=c("character", "character","numeric", "numeric", 
"numeric", "numeric", "numeric", "numeric",
 >> "numeric", "numeric", "numeric", "numeric")
 >> # Error:
 >> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, 
na.strings, (from #2) :

Line #2: (with 'skip=4', so really line 4, but the first line after the 
'header', as indicated above)

LAE;201001010000;2;894.6;3.9;93.8;5.3;3.1;204


>> scan() expected 'a real',  got '894.6'
 >>
 >> How is '894.6' not 'a real [number]'?
 >>
 >> Thanks for the ensuing enlightenment or punishment...
 >>
 >> Best,
 >> Brian
 >>
 >> ______________________________________________
 >> 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.

my full command:

   read.csv2(file=file, skip=2, na.strings = "-",
             colClasses=c("character", "character","numeric", "numeric",
               "numeric", "numeric", "numeric", "numeric"))

Also, sorry I forgot this:

R version 2.15.1 (2012-06-22)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  base

other attached packages:
[1] MASS_7.3-18

Thanks again.
Brian




More information about the R-help mailing list