Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

国外省份翻译问题 #64

Open
MarkYueMa opened this issue Mar 20, 2020 · 2 comments
Open

国外省份翻译问题 #64

MarkYueMa opened this issue Mar 20, 2020 · 2 comments

Comments

@MarkYueMa
Copy link

MarkYueMa commented Mar 20, 2020

余老师您好,
在英文版本windows下国外省份翻译出现无法识别问题,以下为示例:
R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 6.2
year 2019
month 12
day 12
svn rev 77560
language R
version.string R version 3.6.2 (2019-12-12)
nickname Dark and Stormy Night

library(nCov2019)
x<-load_nCov2019(lang`` = "auto")
Warning messages:
1: In readRDS(system.file("country_translate.rds", package = "nCov2019")) :
strings not representable in native encoding will be translated to UTF-8
nCov2019_set_country("China")
China<-x[]
nCov2019_set_country("United States")
US<-x[]

head(China)
time country province city cum_confirm cum_heal cum_dead suspected
2019-12-01 China Hubei Wuhan 1 0 0 0
2019-12-02 China Hubei Wuhan 1 0 0 0
2019-12-03 China Hubei Wuhan 1 0 0 0
2019-12-04 China Hubei Wuhan 1 0 0 0
head(US)
time country province cum_confirm cum_heal cum_dead suspected
2020-03-15 United States 769 1 42 NA
2020-03-15 United States 746 0 6 NA
2020-03-15 United States 431 2 6 NA
2020-03-15 United States 164 1 0 NA
美国各州的名字因为encoding问题直接无法显示,在Rstudio中为
切换为中文后显示为UTF-8
time country province
2020-03-15 <U+7F8E><U+56FD> <U+534E><U+76DB><U+987F><U+5DDE>
2020-03-15 <U+7F8E><U+56FD> <U+7EBD><U+7EA6><U+5DDE>

@timze216
Copy link
Collaborator

指定了字符编码为 UTF-8, 请问现在问题解决了吗?

@MarkYueMa
Copy link
Author

MarkYueMa commented Mar 21, 2020

你好,十分感谢你的回复。在更新package以后重试以上代码还是有以下warning

Warning messages:
1: In readRDS(system.file("country_translate.rds", package = "nCov2019")) :
  strings not representable in native encoding will be translated to UTF-8
2: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  invalid input found on input connection 'E:/Users/vespe/Documents/R/win-library/3.6/nCov2019/oversea_cityname_zh_en.csv'
3: In load(system.file("ncovEnv.rda", package = "nCov2019")) :
  strings not representable in native encoding will be translated to UTF-8
4: In load(system.file("ncovEnv.rda", package = "nCov2019")) :
  strings not representable in native encoding will be translated to UTF-8
5: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  invalid input found on input connection 'E:/Users/vespe/Documents/R/win-library/3.6/nCov2019/oversea_cityname_zh_en.csv'
6: In load(system.file("ncovEnv.rda", package = "nCov2019")) :
  strings not representable in native encoding will be translated to UTF-8

导出的dataframe依然无法显示省份, 我查看了oversea_cityname_zh_en.csv以及country_zh_en.csv。我的excel也无法识别其中的中文字符, 如果能修改这两个文件的encoding的话应该就能解决这个问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants