[R] Writing Persian (Arabic) in a data frame

John Kane jrkr|de@u @end|ng |rom gm@||@com
Tue Jul 28 15:51:07 CEST 2020


Just to agree with the other responses, note my default encoding is UTF-8.

> A<-data.frame(x=c("مریم","ماریا"),y=c(1,1))
> A
      x y
1  مریم 1
2 ماریا 1
> str(A)
'data.frame': 2 obs. of  2 variables:
 $ x: chr  "مریم" "ماریا"
 $ y: num  1 1
>  sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C
LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8
 [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8
 LC_PAPER=en_CA.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C

On Tue, 28 Jul 2020 at 08:32, Ivan Krylov <krylov.r00t using gmail.com> wrote:

> On Tue, 28 Jul 2020 10:31:07 +0430
> Vahid Borji <vahid.borji65 using gmail.com> wrote:
>
> > A<-data.frame(x=c("مریم","ماریا"),y=c(1,1))
>
> > 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
>
> This is one of those problems heavily affected by your version of R
> (does it have stringsAsFactors = TRUE or FALSE by default?), your
> operating system and locale (see [*] for a description of
> Unicode-related problems in R on Windows).
>
> Here is a similar problem from 9 years ago where Unicode characters
> were displayed as escapes on Windows with US English (ANSI-1251)
> locale when data.frame() converted strings to factors:
>
> https://r.789695.n4.nabble.com/gsub-with-unicode-and-escape-character-td3672737.html
>
> --
> Best regards,
> Ivan
>
> P.S.
>
> >       [[alternative HTML version deleted]]
>
> Please post in plain text, not HTML.
>
> [*]
>
> https://developer.r-project.org/Blog/public/2020/05/02/utf-8-support-on-windows/index.html
>
> ______________________________________________
> 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.
>


-- 
John Kane
Kingston ON Canada

	[[alternative HTML version deleted]]



More information about the R-help mailing list