I am working with Emacs 24 on Mac OS X 10.7.3 with R 2.14.0. I have a file foo.Rnwcontaining
\documentclass[
paper=a4,% 210mm × 297mm
pagesize% write page size to dvi
]{article}
\usepackage[american]{babel}
\usepackage{fancyvrb}
\usepackage[utf8]{inputenc}
\SweaveOpts{engine=R}
\SweaveOpts{pdf=TRUE}
\begin{document}
Some text
<<>>=
sessionInfo()
@
\end{document}
My .emacsfor work with Sweave looks like this:
(add-hook 'Rnw-mode-hook
(lambda ()
(add-to-list 'TeX-command-list
'("Sweave" "R CMD Sweave %s"
TeX-run-command nil t :help "Run Sweave") t)
(add-to-list 'TeX-command-list
'("Stangle" "R CMD Stangle %s"
TeX-run-command nil t :help "Run Stangle") t)
(setq TeX-command-default "Sweave")))
If I use C-c C-c, and then select Sweave, the file .texlooks like this:
\documentclass[
NA
pagesize% write page size to dvi
]{article}
\usepackage[american]{babel}
\usepackage{fancyvrb}
\usepackage[utf8]{inputenc}
\usepackage{Sweave}
\begin{document}
Some text
\begin{Schunk}
\begin{Sinput}
> sessionInfo()
\end{Sinput}
\begin{Soutput}
R version 2.14.0 (2011-10-31)
Platform: x86_64-apple-darwin11.2.0/x86_64 (64-bit)
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_2.14.0
\end{Soutput}
\end{Schunk}
\end{document}
, foo.Rnw, -ASCII ×, NA. , , R (. locale: [1] C. export LC_MESSAGES="en_US.UTF-8" export LC_MESSAGES="en_US.UTF-8", R locale. R CMD Sweave foo.Rnw (, , .bashrc , , locale). : Emacs, Sweave C-c C-c Sweave? , Emacs , .bashrc, , R CMD Sweave, Emacs, , ?
, Mac Emacs. , R CMD Sweave foo.Rnw (- .bashrc) - - Emacs ( ).
UPDATE:
My ~/.bashrc :
export LC_COLLATE="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_MONETARY="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
Yihui, ~/.Rprofile:
invisible(Sys.setlocale("LC_COLLATE", "en_US.UTF-8"))
invisible(Sys.setlocale("LC_CTYPE", "en_US.UTF-8"))
invisible(Sys.setlocale("LC_MONETARY", "en_US.UTF-8"))
invisible(Sys.setlocale("LC_TIME", "en_US.UTF-8"))
invisible(Sys.setlocale("LC_MESSAGES", "en_US.UTF-8"))
.