Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

knitr and UTF8 encoding

Tags:

r

latex

knitr

A few days ago, I started writing on a german R-Script. Unfortunately, the following code chunk doesn't work when I knit() the document:

@    
<<>>=
äö <- ordered(c(1,3,2,2))
@

Can anyone help me solve this problem?

PS: I'm working with Linux.

like image 426
beginneR Avatar asked Jun 26 '12 20:06

beginneR


1 Answers

Since you are using Linux, things should be easy. It is probably just a LaTeX problem; most importantly, did you specify the encoding of your document? e.g. \usepackage[utf8]{inputenc}. This works for me under Ubuntu.

\documentclass[ngerman]{article}
\usepackage[utf8]{inputenc}
\begin{document}

<<>>=
äö <- ordered(c(1,3,2,2))
@

\end{document}

BTW, perhaps it is not a good idea to use non-ASCII characters in R object names, although they also work.

like image 147
Yihui Xie Avatar answered Oct 13 '22 12:10

Yihui Xie