[R] Sweave produces gibberish instead of apostrophe in pdf

Paul Hiemstra p.hiemstra at geo.uu.nl
Wed Feb 27 11:35:23 CET 2008


Dear All,

I try to use Sweave to make a document. But when I use the Sweave() 
command on it and build a pdf with pdflatex (3.141592-1.40.3) my 
apostrophes are replaced by some gibberish (an 'a' with a hat on it, a 
capital A with a arc pointing upwards on it and a capital Y with two 
points on it). If I manually replace the apostrophes using the keyboard, 
I get a different looking apostrophe and the output is correct.

I'm using Debian Linux (Lenny) with TexLive, Kile and R 2.6.1.

This is a sample, the problem is in the lm output in the "Signif. codes" 
line:

\documentclass[a4paper,10pt]{article}
\title{Spam}
\author{F. Bar}

\begin{document}
<<reg>>=
n <- 50
x <- seq(1, n)
a.true <- 3
b.true <- 1.5
y.true <- a.true + b.true * x
s.true <- 17.3
y <- y.true + s.true * rnorm(n)
out1 <- lm(y ~ x)
summary(out1)
@
\end{document}

And the resulting .tex file:

\documentclass[a4paper,10pt]{article}
\title{Spam}
\author{F. Bar}

\usepackage{Sweave}
\begin{document}
\begin{Schunk}
\begin{Sinput}
 > n <- 50
 > x <- seq(1, n)
 > a.true <- 3
 > b.true <- 1.5
 > y.true <- a.true + b.true * x
 > s.true <- 17.3
 > y <- y.true + s.true * rnorm(n)
 > out1 <- lm(y ~ x)
 > summary(out1)
\end{Sinput}
\begin{Soutput}
Call:
lm(formula = y ~ x)

Residuals:
Min 1Q Median 3Q Max
-31.9565 -9.4745 -0.1708 7.3759 44.6538

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.07386 4.64712 -0.016 0.987
x 1.57405 0.15860 9.924 3.25e-13 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 .’ 0.1 ‘ ’ 1

Residual standard error: 16.18 on 48 degrees of freedom
Multiple R-Squared: 0.6723, Adjusted R-squared: 0.6655
F-statistic: 98.49 on 1 and 48 DF, p-value: 3.245e-13
\end{Soutput}
\end{Schunk}
\end{document}

cheers and thanks for any help,
Paul

-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone: 	+31302535773
Fax:	+31302531145
http://intamap.geo.uu.nl/~paul



More information about the R-help mailing list