如何在R图中显示đ,ư,ơ,ă [英] how to display đ, ư, ơ, ă in R graphs

查看:385
本文介绍了如何在R图中显示đ,ư,ơ,ă的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在R图表中放置越南语标签。我使用RStudio并保存我的代码使用UTF-8编码。它处理我放在代码中的越南字符,我的意思是一切显示在代码中正确。但是,在我创建的图表中,虽然许多字符显示正常,但几个重要的字符不正确显示,包括



đ - 显示不正确d



ư - 不正确显示为u



ơ - 不正确显示为o



ă - 不正确显示为



不幸的是,这使我的图表看起来不专业,不可信。



非常感谢。








@DWin:我在Windows 7上,这里是我的sessionInfo()

  R版本2.15.0(2012-03-30)
平台:x86_64-pc-mingw32 / x64(64位)

locale:
[1] LC_COLLATE = English_United States.1252 LC_CTYPE = English_United States.1252
[3] LC_MONETARY = English_United States.1252 LC_NUMERIC = C
[5] LC_TIME =英语_United States.1252

附加的基础包:
[1] stats graphics grDevices utils数据集方法base

通过命名空间加载(并未附加):
[1] MASS_7.3-17 MatchIt_2.4-20 tools_2.15.0






@krlmlr:这是一个简单图形的代码:

  knorelative.count < (nrow = 5,ncol = 1)
knorelative.count [,1]< - c(1579,638,215,100,120)

par(mar = c )
barplot(prop.table(knorelative.count),beside = TRUE,
yaxt =n,ylim = c(0,.6),
legend = c ,
nửabiết,nửakhôngbiết,
biếtnhiềuhơnkhôngbiết,
tấtcảđều,
khôngbiếtnhiềuhơnbiết b $ b轴(2,at = seq(0,.6,.1),labels = paste(100),
main =ngờ * seq(0,.6,.1),%,sep =),las = 1)

当我运行这个时,主标题中的đ,以及图例中的两个Æ和đ变成d和o。

解决方案

您通常使用十六进制代码更安全地指定unicode字符:

  plot(1:4,rep (1,4),pch = c(\\\đ,\\\ư,\\\ơ,\\\ă),cex = 4)


I am trying to put Vietnamese labeling in R graphs. I use RStudio and save my code using UTF-8 encoding. It handles the Vietnamese characters I put in the code well, I mean everything shows up in the code properly. However, in the graphs I make, while many characters display OK, several important ones do not show up properly, including

đ - which displays incorrectly as d

ư - which displays incorrectly as u

ơ - which displays incorrectly as o

ă - which displays incorrectly as a

Unfortunately this makes my graphs look unprofessional and untrustworthy.

I would really appreciate it if someone can help me figure this out.

Thanks much!

Trang


@DWin: I am on Windows 7, and here is my sessionInfo()

R version 2.15.0 (2012-03-30)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] MASS_7.3-17    MatchIt_2.4-20 tools_2.15.0  


@krlmlr: Here's my code for a simple graph:

knorelative.count <- matrix(nrow=5,ncol=1)
knorelative.count[,1] <- c(1579,638,215,100,120)

par(mar=c(2,4,4,2))
barplot(prop.table(knorelative.count),beside=TRUE,
        yaxt="n",ylim=c(0,.6),
        legend=c("không ai biết",
                 "không biết nhiều hơn biết",
                 "nửa biết, nửa không biết",
                 "biết nhiều hơn không biết",
                 "tất cả đều biết"),
        main="Người khác trong gia đình, họ hàng biết hay không")
axis(2,at=seq(0,.6,.1),labels=paste(100*seq(0,.6,.1),"%",sep=""),las=1)

When I run this, the đ in the main title and the two ơ's and the đ in the legend turn into d and o.

解决方案

You are often safer specifying unicode characters by their hex codes:

plot(1:4,rep(1,4),pch=c("\u0111","\u01B0","\u01A1","\u0103"),cex=4)

这篇关于如何在R图中显示đ,ư,ơ,ă的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆