[R] type.convert error with read.csv function

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Apr 19 23:54:38 CEST 2005


On Tue, 19 Apr 2005, Ivan Alves wrote:

> Dear all,
>
> I obtained and successfully compiled R 2.1.0 on Mac OSX 10.3.9.  The
> flags used for configuration are:
>
> ./configure --enable-utf8 --enable-R-shlib --with-blas='-framework
> vecLib' --with-lapack --with-aqua
> --with-tcl-config=/Library/Frameworks/Tcl.framework/tclConfig.sh
> --with-tk-config=/Library/Frameworks/Tk.framework/tkConfig.sh
> TCLTK_LIBS='-framework Tcl -framework Tk'
> TCLTK_CPPFLAGS='-I/Library/Frameworks/Tcl.Framework/Headers
> -I/Library/Frameworks/Tk.Framework/Headers'
>
> A straight-forward read.csv[] function returns the following error:
>
> > map.plain <- read.csv("~/Projects/ProjectMap/plain.csv", na.strings =
> ".")
> Error in type.convert(data[[i]], as.is = as.is[i], dec = dec,
> na.strings = character(0)) :
> 	invalid multibyte string
>
> I had used the exact command with R 2.0.1 compiled with almost exactly
> the same configuration (except the utf8 support) and had no errors.
> Could you please enlighten this unknowledgeable soul as to the nature
> of the problem?  I searched in R-help digest to no avail.  Thank you
> very much in advance.

First port of call is the manuals.  Since this is a new version of R, you 
need to read the new versions.

The issue is that you are in a UTF-8 locale, and your file is not in 
UTF-8.  You need to tell R what encoding it is in: please read the manual 
`R Data Import/Export'.  (Discussed in section 2.1 in the HTML version.)


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list