strange characters: interaction of R and Windows locale?

后端 未结 2 1824
[愿得一人]
[愿得一人] 2020-12-16 15:23

WinXP-x32, R-2.13.0

Dear list,

I have a problem that (I think) relates to the interaction between Windows and R.

I am trying to scrape a table with d

2条回答
  •  心在旅途
    2020-12-16 16:11

    A not quite an answer:

    If you look at the wikipedia page and change the encoding in your browser (in IE, View -> Encoding; in Firefox, View -> Character Encoding) to Western (ISO-8869-1) or Western (Windows-1252) then you see the silly characters. That ought to mean that you can use iconv to change the encoding and fix your problems.

    #Convert factors to character
    Islands <- as.data.frame(lapply(Islands, as.character), stringsAsFactors = FALSE)
    
    iconv(Islands$Island, "windows-1252", "UTF-8")
    

    Unfortunately, it doesn't work. It may be possible to get the correct text by using a different conversion (iconvlist() shows all the possibilities).

    It is possible it simply strip out the offending characters, though this isn't ideal.

    iconv(Islands$Island, "windows-1252", "ASCII", "")
    

提交回复
热议问题