Sweave and LaTeX Sweave and LaTeX: LaTeX "preamble" to use in your .nw file: Sweave.Template.nw
Sweave Manual and example .nw Sweave files used in the Sweave manual can be found here.
LaTeX can be found here.
Sweave from within Emacs
\end{document} expression if you get the following error from Sweave:Warning message: incomplete final line found by readLines on `blah.nw'
.nw file: % (percent) signs (the LaTeX comment symbol) to comment out lines of text and whole R code chunks (i.e., from the <<>>= to the @ headers).
# (number) signs (the R comment symbol) to comment out lines of R code within an R code chunk (i.e., between the <<>>= to the @ headers).
Sweave as a batch process outside of R (i.e., from a konsole command prompt), run this command: R CMD Sweave foo.Rnw , replacing .Rnw with .nw or whatever you use for the file suffix. You may want to run this command after R finishes if you have set up to use a directory graphics and forgot to tell Sweave not to create .eps files when you are using pdflatex : rm -f Rplots.ps graphics/*.eps
Sweave documents. .nw file used to create the linked pdf file: RCitation.nw
.bib file to create and reference: Rbiblioref.bib
upData() function invocation to generate a long variable label that will automatically wrap in the LaTeX version of a summary.formula() (with reverse = TRUE) table. The strwrap() function width= argument will dictate how wide the label is.
x <- data.frame(var1 = sample(1:100, size = 250, replace = TRUE), group = sample(c("A", "B"), size = 250, replace = TRUE)) x <- upData(x, labels = c(var1 = paste(strwrap(paste("This is an extremely long and descriptive", "variable label that would normally run off the page.", "Our goal is to break this variable label over multiple lines so we won't have to", "truncate the variable label in any way."), width = 60), collapse = "\\\\"))) latex(summary(group ~ var1, method = "reverse", data = x, overall = TRUE, file = "", landscape = TRUE))