Re: [R] Sweave produces gibberish instead of apostrophe in pdf

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed, 27 Feb 2008 11:25:30 +0000 (GMT)

These are not 'apostrophe's: it's (that is an apostrophe) misleading to call them that. They are single quotes, and there are two sorts if you look carefully.

Probably you are using a UTF-8 locale and not telling LaTeX (or us) so. There are several ways to do so, depending on the age of your LaTeX setup.

\usepackage[utf8]{inputenc}

is one.

Alternatively, you can tell R not to use UTF-8 quotes with options(useFancyQuotes=FALSE).

Please note the 'at a minimum' information the posting guide asked you for -- it included the locale.

On Wed, 27 Feb 2008, Paul Hiemstra wrote:

> 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
>
> ______________________________________________
> 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.
>

-- 
Brian D. Ripley,                  ripley_at_stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


______________________________________________ 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.

Received on Wed 27 Feb 2008 - 11:30:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 27 Feb 2008 - 12:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive