[R-SIG-Mac] Unable to read.csv because of special character in file
Simon Urbanek
simon.urbanek at r-project.org
Tue Jan 20 18:27:03 CET 2009
Please read ?read.csv, most notably about encoding. Apparently your
file is in Latin1 so have forgotten to specify encoding="latin1".
Cheers,
S
On Jan 20, 2009, at 12:07 , Dennis Fisher wrote:
> Colleagues,
>
> I am trying to read a file that contains the µ (mu character).
> readLines is succcessful and shows the following:
> "\xb5g/mL\"
>
> read.csv yields the following:
>> Error in type.convert(data[[i]], as.is = as.is[i], dec = dec,
>> na.strings = character(0)) :
>> invalid multibyte string at '<b5>g/mL'
>
> using a text editor, i replaced all occurrences of µ (mu) - at which
> point read.csv worked properly.
>
> sessionInfo()
>> R version 2.8.0 (2008-10-20)
>> i386-apple-darwin8.11.1
>>
>> locale:
>> en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>>
>> attached base packages:
>> [1] stats graphics grDevices utils datasets methods base
>>
>
>
> Although my work-around was successful, I am wondering whether there
> is some means to accomplish this without editing the source document:
> 1. is it possible to inform R to read the character in its natural
> form?
> 2. if not, I could execute readLines, then do a gsub (which did not
> work - any ideas of how to formulate the regular expression would be
> appreciated). then write to a tempfile and read in again (or use a
> textConnection).
>
> Dennis
>
> Dennis Fisher MD
> P < (The "P Less Than" Company)
> Phone: 1-866-PLessThan (1-866-753-7784)
> Fax: 1-415-564-2220
> www.PLessThan.com
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>
>
More information about the R-SIG-Mac
mailing list