knitr and UTF8 encoding

江枫思渺然 提交于 2019-12-23 08:46:11

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/11215808/knitr-and-utf8-encoding

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!