Reputation: 318
I am trying to get Arabic text to display correctly in R on a Mac. Currently when i produce plots in Arabic, i have to switch to Windows. Windows correctly displays Arabic in R. However in Mac, I can't get Arabic to display right to left.
I have tried using various Unicode escape characters to no avail. My understanding was that these characters are supposed to force a reading from right to left.
example1 <- data.frame(item = "مرحبا")
example1$item <- paste("\u202B", example1$item)
ggplot(example1, aes(item)) +
geom_bar() +
theme(axis.text.x = element_text(size = 25))
The title should like thusly: مرحبا.
I know that others have been able to fix this problem by using plotly package, which will correctly display Arabic text. But if the Arabic text is longer than one line, plotly won't display it properly wrapped over two lines. So I am looking for a solution that involves fixing the encoding.
Upvotes: 8
Views: 301