[R] Sweave special characters problem

Bunny, lautloscrew.com bunny at lautloscrew.com
Thu Jul 22 23:07:13 CEST 2010


Thx everybody, 

finally I got it to go. I switched all three files (mysource.R, sweavetemplate.Rnw,invokeSweave.R) to UTF-8 encoding, switched the options() like suggested below and it just worked.

On 22.07.2010, at 16:11, David Winsemius wrote:

> 
> On Jul 22, 2010, at 9:39 AM, Bunny, lautloscrew.com wrote:
> 
>> Sorry all,
>> 
>> for not posting a minimal example. I am running R on Mac OS X snow leopard with Komodo edit / Sciviews-R. The problem is that the code does not work any more if there is an umlaut in my R code. The error message is some strange mixture of german and english, so this what the error message is supposed to look like:
>> "Invalid multibyte character in Parser line 195" . Allan´s example works as a standalone, with his code I get the following error message. Maybe this is a mac problem ...
>> 
>> Error in parse(text = chunk) :
>> Unexptected entry in "x <- data.frame(GeschÂ"
> 
> 
> I ran Allan Englehart's example and got the expected result on R 2.11.1 with Mac OS 10.5.8.
> 
> Seems possible that this is specific to Komodo Edit/Sciviews-R. I tried getting that editor/system to work as an editing environment a year ago and formed the opinion that there were too many got-cha's in the specification of options and user environments. I gave up and went back to a less complex (and in my hands, less fragile) strategy. I would take your question to whatever support site is available for Sciviews-R. (I suppose it could be a Leopard vs Snow Leopard issue, but do not have the resources to investigate.)
> 
> -- 
> David "all thumbs with Unix" Winsemius
> 
> > sessionInfo()
> R version 2.11.1 Patched (2010-06-14 r52281)
> x86_64-apple-darwin9.8.0
> 
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
> 
> attached base packages:
> [1] grid      splines   stats     graphics  grDevices utils     datasets  methods
> [9] base
> 
> other attached packages:
> [1] xtable_1.5-6    mgcv_1.6-2      prettyR_1.8-1   sos_1.2-9       brew_0.1-1
> [6] doBy_4.0.6      MASS_7.3-6      rms_3.0-0       Hmisc_3.8-1     survival_2.35-8
> [11] panel_1.0.7     quantreg_4.50   SparseM_0.85    lattice_0.18-8
> 
> loaded via a namespace (and not attached):
> [1] cluster_1.12.3     Matrix_0.999375-40 nlme_3.1-96        tools_2.11.1
> 
>> 
>> 
>> 
>> Thx for any help in advance
>> 
>> best
>> 
>> matt
>> 
>> 
>> 
>> 
>> On 22.07.2010, at 14:47, Allan Engelhardt wrote:
>> 
>>> A standalone example is always helpful.  The following works for me, so I am probably not understanding your problem:
>>> 
>>> ---[BEGIN: umlaut.Rnw]---
>>> \documentclass[a4paper]{article}
>>> \usepackage{ucs}
>>> \usepackage[utf8x]{inputenc}
>>> 
>>> \begin{document}
>>> 
>>> <<test,echo=TRUE>>=
>>> x <- data.frame(Geschäftslage=1:10)
>>> summary(x)
>>> @
>>> \end{document}
>>> ---[END: umlaut.Rnw]---
>>> 
>>> $ R CMD Sweave umlaut.Rnw
>>> $ R CMD pdflatex umlaut.tex
>>> $ gnome-open umlaut.pdf
>>> 
>>> Allan
>>> 
>>> 
>>> On 22/07/10 13:19, 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!
>>>> 
>>>> best
>>>> 
>>>> matt
>>>> 
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>> 
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> David Winsemius, MD
> West Hartford, CT
> 



More information about the R-help mailing list