amin roshani amin roshani - 5 months ago 41
R Question

farsi character in knitr

I am using knitr 1.13 in R 3.3.1 and within RStudio and having problems with knitr recognizing Farsi characters. I am saving below code in

file and then run
but Farsi characters change to
in output.

\usepackage{xepersian}%package for type Farsi in LaTex
این یک متن آزمایشی است
fit <- lm(dist ~ speed, data = cars)
برای آزمایش داریم:

  1. Ensure that the file is saved in UTF-8 encoding
  2. On most operating systems, that’s enough, since UTF-8 is the system’s default encoding anyway. Especially on Windows, you additionally need to specify the encoding when knitting, e.g.:

    knit('filename.rnw', encoding = 'UTF-8')