Peter Dunn
2007-Mar-07 05:33 UTC
[R] Sweave issue: quotes in verbatim-like output print incorrectly
Hi all I love Sweave; use it all the time. But I recently received a new computer, and ever since I have had a problem I've never seen before. For example, I place the following in my Snw file: <<>>sms <- read.table("http://www.sci.usq.edu.au/staff/dunn/Datasets/applications/popular/smsspeed.dat", header=TRUE) attach(sms) sms.lm <- lm( Time ~ Age*Phone, subset=(Age>30) ) summary(sms.lm) @ Standard stuff. The output appears in the corresponding LaTeX file as it should, in a verbatim-like environment as it should. But since I have had this new machine, this line of output: Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 appears in my resulting pdf document as Signif. codes: 0 ^a?A?Y***^a?A?Z0.001 ^a?A?Y**^a?A?Z0.01 ^a?A?Y*^a ?A?Z0.05 ^a?A?Y.^a?A?Z0.1 ^a?A?Y^a?A?Z1 In short, every quote is replaced by garbage. This makes my output looks incredibly bad. (This is true for all cases; the above is the output from my example.) I also imagine (hope!) there is a very simple fix. Can anyone help me? Documents which used to produce the correct output document now do this, so it must be something to do with my machine set up, or R set up, rather than the documents themselves, I guess. Any help appreciated. I have no idea where to look for the solution (the FAQ. manuals and mailing archives were no help that I could see; happy to be corrected). P.> version_ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status Patched major 2 minor 4.0 year 2006 month 11 day 25 svn rev 39997 language R version.string R version 2.4.0 Patched (2006-11-25 r39997)> sessionInfo()R version 2.4.0 Patched (2006-11-25 r39997) i486-pc-linux-gnu locale: LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=en_AU.UTF-8;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" [7] "base" -- Dr Peter Dunn | dunn <at> usq.edu.au Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc This email (including any attached files) is confidential an...{{dropped}}
Gavin Simpson
2007-Mar-07 09:37 UTC
[R] Sweave issue: quotes in verbatim-like output print incorrectly
On Wed, 2007-03-07 at 15:33 +1000, Peter Dunn wrote:> Hi all > > I love Sweave; use it all the time. > > But I recently received a new computer, and ever since I > have had a problem I've never seen before. > > For example, I place the following in my Snw file:Try this in the preamble of your Snw file: \usepackage[utf8x]{inputenc} (assuming you have the inputenc package installed and available). I'm assuming you are now using a machine using UTF-8 for character encodings. I used to get that output on my linux box (FC4 - 6) before I added the above \usepackage statement. HTH G> > <<>>> sms <- > read.table("http://www.sci.usq.edu.au/staff/dunn/Datasets/applications/popular/smsspeed.dat", > header=TRUE) > attach(sms) > > sms.lm <- lm( Time ~ Age*Phone, subset=(Age>30) ) > summary(sms.lm) > @ > > Standard stuff. The output appears in the corresponding LaTeX > file as it should, in a verbatim-like environment as it should. > > But since I have had this new machine, this line of output: > > Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > appears in my resulting pdf document as > > Signif. codes: 0 ^a?A?Y***^a?A?Z0.001 ^a?A?Y**^a?A?Z0.01 ^a?A?Y*^a > ?A?Z0.05 ^a?A?Y.^a?A?Z0.1 ^a?A?Y^a?A?Z1 > > In short, every quote is replaced by garbage. This makes my > output looks incredibly bad. (This is true for all cases; the above > is the output from my example.) > > I also imagine (hope!) there is a very simple fix. Can anyone help me? > > Documents which used to produce the correct output document > now do this, so it must be something to do with my machine > set up, or R set up, rather than the documents themselves, I guess. > > Any help appreciated. I have no idea where to look for the solution > (the FAQ. manuals and mailing archives were no help that I could see; > happy to be corrected). > > P. > > > > version > _ > platform i486-pc-linux-gnu > arch i486 > os linux-gnu > system i486, linux-gnu > status Patched > major 2 > minor 4.0 > year 2006 > month 11 > day 25 > svn rev 39997 > language R > version.string R version 2.4.0 Patched (2006-11-25 r39997) > > > sessionInfo() > R version 2.4.0 Patched (2006-11-25 r39997) > i486-pc-linux-gnu > > locale: > LC_CTYPE=en_AU.UTF-8;LC_NUMERIC=C;LC_TIME=en_AU.UTF-8;LC_COLLATE=en_AU.UTF-8;LC_MONETARY=en_AU.UTF-8;LC_MESSAGES=en_AU.UTF-8;LC_PAPER=en_AU.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_AU.UTF-8;LC_IDENTIFICATION=C > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" > [7] "base" >-- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC [f] +44 (0)20 7679 0565 UCL Department of Geography Pearson Building [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street London, UK [w] http://www.ucl.ac.uk/~ucfagls/ WC1E 6BT [w] http://www.freshwaters.org.uk/ %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%