[R] Sweave special characters problem

Duncan Murdoch murdoch.duncan at gmail.com
Thu Jul 22 14:44:59 CEST 2010


On 22/07/2010 8:19 AM, Bunny, lautloscrew.com wrote:
> Dear all, 
>
> I use Sweave to create my reports. Unfortunately my script crashes whenever I my R code contains special characters like umlauts. 
> Is there a way to to escape special characters in Sweave... This is the line that crashes Sweave:
>
> gl_bybranch = ddply(new_wans,.(period,Branchen), function(X) data.frame(Geschäftslage=mean(X$sentiment)))
>
> Unfortunately I can't just rename it, because I it´s displayed in the legend of graphics later on.
>
> Thx for any suggestions! 
>   

I think you need to give us some more details.  What does "my script 
crashes" mean?  Does R fail, or does latex?  What is the error message?

The likely problem is something to do with character encodings.  By 
default, latex usually only accepts plain ascii characters, nothing with 
accents -- but modern versions can handle other encodings if you declare 
them.  So the solution may be as simple as declaring the encoding at the 
top of your .Rnw file, e.g.

\usepackage[utf8]{inputenc}


if you are using the UTF-8 encoding.

Duncan Murdoch



More information about the R-help mailing list