Right to left languages support in R, using Mac

帅比萌擦擦* 提交于 2019-12-09 07:53:47

问题


I am wondering if there is anyway to support right-to-left languages in R while using Mac

For instance suppose the following code:

x <- data.frame(a=runif(10),b=runif(10))
ggplot(x, aes(a,b)) + geom_point() + xlab("سلام")

Here is the result:

Here I tried to change the x-label as a Persian/Arabic word (سلام = Hello). While displayed correctly in the code (using R-Studio), in the graph the characters of سلام are displayed in the reverse order (left-to-right).

Also the linkage between two consecutive letters (i.e. س connected to ل would be سل) is broken.

Do you have any idea how to fix it?

Update

With the answer of @agstudy I found R under Ubuntu is perfectly OK. However I have no idea how to solve the problem in Mac (OS X 10.9.1) having updated version of R and R-Studio


回答1:


It works fine for me. I just change the size of labels to better show it.

library(ggplot2)
x <- data.frame(a=runif(10),b=runif(10))
ggplot(x, aes(a,b)) + 
  geom_point()+ xlab('سلام') +
  theme( axis.title=element_text(size=100,face="bold"))

I am using :

other attached packages:
[1] ggplot2_0.9.3.1
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

Also works fine under :

R version 3.0.3 (2014-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)



回答2:


I had the same problem with Hebrew letters, and I manage to work around it by reading the label from an Excel file instead of typing it directly into R studio. This method works as long as you don't need to mix letters with numbers, in that case things start to get messy. for example:



来源:https://stackoverflow.com/questions/22423760/right-to-left-languages-support-in-r-using-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!