[R] declaring constants in an Sweave / LaTeX document

From: Kyle Matoba <kmmatoba_at_ucdavis.edu>
Date: Fri, 21 Nov 2008 23:01:39 -0800


I would like to set a variable to hold, say, the size of my plots in a Sweave document. i.e. something like the following in my '.Rnw' file:

smallPlotSize = 4

<<fig1, echo=false, results=hide, height=smallPlotSize, width=smallPlotSize, fig=true>>=
dat <- read.table("
http://www.stanford.edu/~xing/statfinbook/_BookData/Chap05/q_us_gdp.txt", skip=2, header=T)

GDP <- ts(data=dat$VALUE, start=c(1947,1), frequency=4)

acf(GDP, type="correlation", main= "ACF of US GDP") @

This way I can tweak things if I have to include a bunch of graphics of the same size in a file. I am not great with LaTeX and still very new to using Sweave, so I was wondering what the preferred method of doing something like this is between LaTeX and Sweave. I have seen some people doing some tricky stuff from within R such that when their code is preprocessed it is compiled as LaTeX source, but this seems like an ugly hack for something so simple.

Please forgive me if this has been addressed elsewhere; I have found documentation on Sweave to be rather sparse.



        [[alternative HTML version deleted]]

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 Sat 22 Nov 2008 - 11:17:42 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 Sat 22 Nov 2008 - 17:30:27 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