Reading Arabic data text in R and plot ()

R doesn't handle Arabic text very well. Although you can enter some Arabic strings like

Names <- c("سليم", "سعيد", "مجدى"). 

Now I use a word or excel to write longer lists of the name and save the file as text. I can import the file into R (RStudio) and display the imported data correctly. However, I cannot manipulate the imported list. For example, drawing draws funny characters. why directly printed lists (not easy at all) can be built but not an imported list?

I use Windows 7, R v.3.0.2 and RStudio to read a file.

Any help on using the Arabic text in R would be greatly appreciated. Thanks

+6
source share
1 answer

If you save the text with the encoding "UTF-8" (for example, using Rstudio, create a text file, and then use the menu "Save with encoding ..." and select UTF-8), then you can read it easily:

 readLines('d:/temp/arabic.txt',encoding='UTF-8') [1] "\"سليم\" \"سعيد\" \"مجدى\"" 

Or using scan :

 scan("arabic",encoding='UTF-8',what='character',sep=',') Read 3 items [1] "سليم" " سعيد" " مجدى " 
+5
source

All Articles