On Wed, 23 Jan 2008, David Scott wrote:

>
> I have encountered a problem with reading a .csv file on a linux box. I
> can read the file on my windows machine (under XP) but on the linux box it
> gives :
>
>> patients <- read.csv("../Patients.csv", header = FALSE,
> +                      col.names = patientsNames)
> Error in type.convert(data[[i]], as.is = as.is[i], dec = dec,
> na.strings = character(0)) :
>   invalid multibyte string
> Calls: read.csv -> read.table -> type.convert
> Execution halted
>
> I am running R 2.6.1 on both machines. I tried on another linux box
> running 2.5.1 and got the same problem
>
> I am guessing it is something to do with the character encoding. On the
> linux box I have
>
> LANG=en_US.UTF-8

So what encoding is the .csv file in?  Consider the example at the end of 
?file

      ## examples of use of encodings
      cat(x, file = file("foo", "w", encoding="UTF-8"))
      # read a 'Windows Unicode' file including names
      A <- read.table(file("students", encoding="UCS-2LE"))

and adapt accordingly (encoding = "CP1252" is the most likely value if 
this works in English-language Windows).

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
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

______________________________________________
R-help@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.

Reply via email to