[R] Writing Persian (Arabic) in a data frame
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Tue Jul 28 13:57:50 CEST 2020
On 28/07/2020 2:01 a.m., Vahid Borji wrote:
> I am trying to make a data frame including two vectors. The first vector is
> a vector of Persian names, and the second vector is a vector of numbers. My
> code is as follows:
>
> A<-data.frame(x=c("مریم","ماریا"),y=c(1,1))
> A
>
> But when I run these codes I do not receive my desired output. Indeed the
> column of x is not in Persian. The output is like this:
>
> x y1
> <U+0645><U+0631><U+06CC><U+0645> 12
> <U+0645><U+0627><U+0631><U+06CC><U+0627> 1
>
> I want to have the column of x in *Persian language*. Could you please help
> me how I can do it?
You need to work on a system that uses a UTF-8 locale. Otherwise R
tries to express strings in the local encoding, finds that won't work,
and shows Unicode escapes instead.
For decades Windows had no UTF-8 locale, so your only choice was to move
to a different OS. There are rumours now that it finally has one, but I
don't know how to enable it, and I'm not certain that R will handle it
properly: you may need a very recent version (perhaps unreleased) for R
not to automatically assume that Windows can't do it.
Duncan Murdoch
>
> (I should say when I make a vector of Persian names and I run it, I receive
> the correct output in Persian, like below:
>
> x=c("مریم","ماریا")
> x[1] "مریم" "ماریا"
>
> But in regard to the data frame I have the above problem)
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list