1

I worked with a data frame which contains data in Persian and English. I didn't have any problem with it and I coded properly and It worked well. This time which I open RStudio The Persian fonts in my code have been corrupted but there is no problem whit new codes which I write now and use Persian font. The problem is I need the previous codes which has been corrupted.For example like this:

x <- V[V$P_AgeGroup=="1.Ú©ÙØ¯Ú©",]
view(x)
y1 <- x[x$P=="Ø·ÙØ§Ù Ú¯Ø±ÙØªÙ",]
View(y1)
y2 <- x[x$P=="ÙÙØ³Ø± ÙÙØª شدÙ",]
view(y2)

It is not my real data but To have a reproducible data if needed:

data <- data.frame(A=c("تهران","همدان","ساری","سمنان","یزد"),B=c(129,32,512,409,105))

By the way, I used below code in the first lines of my code.

Sys.setlocale(locale = "Persian")

Any little help would be greatly appreciated.

fio
  • 11
  • 1
  • Setting locales does not necessarily make the necessary fonts and encodings available. You need to make sure the encodings are equivalent and that you have appropriate fonts. I was surprised that your data data.frame displayed it rows backwards. The first row was "1 تهران 129" and efforts to run your code returned a warning: OS reports request to set locale to "Persian" cannot be honored. (I am on a Linux machine.) – IRTFM Dec 29 '19 at 05:03
  • From help(locales): "Attempts to change the character set by Sys.setlocale("LC_CTYPE") that implies a different character set during a session may not work and are likely to lead to some confusion because it may not affect the native encoding." – IRTFM Dec 29 '19 at 05:21
  • Excuse me, I didn't get what's your solution.should I use Sys.setlocale("LC_CTYPE") instead of SYS.setlocale("Persian")? – fio Dec 29 '19 at 06:43
  • I wasn't offering a solution. I suspect it differs from OS to OS, what is set up as the installation defaults, and whatever fonts are available. None of that is information you offered. – IRTFM Dec 29 '19 at 21:15
  • Possibly addressed by this answer: https://stackoverflow.com/questions/23324872/rstudio-not-picking-the-encoding-im-telling-it-to-use-when-reading-a-file found by doing a search on "[rstudio] encoding" and sorting the hundreds of hits by count of votes. If those answers do lead to a solution, then you should mark your own question as a duplicate. – IRTFM Dec 29 '19 at 22:12

0 Answers0