ignore vignette PDF file
[cacheSweave.git] / inst / example / simpleRR.Rnw
blob1d57337b16f3cd8c1476b34356ed112686da5d1d
1 \documentclass{article}
3 \usepackage[margin=1in]{geometry}
5 \setlength{\parindent}{0in}
7 \title{A Simple Sweave Document using Caching}
8 \author{Roger D. Peng}
10 \SweaveOpts{eps=false}
12 \begin{document}
14 \maketitle
16 First we load the packages which contain the data and functions that
17 we will need later
18 <<LoadPackages>>=
19 library(datasets)
20 library(utils)
23 We fit a linear model to the \texttt{airquality} dataset.  In this
24 code chunk we will turn caching on so that we cache the
25 \texttt{airquality} data frame and the \texttt{fit} object.
26 <<FitLinearModel,cache=true>>=
27 data(airquality)
28 fit <- lm(Ozone ~ Temp + Wind + Solar.R, data = airquality)
31 We can summarize the regression coefficients and their uncertainties
32 in a table
33 <<CoefficientTable,results=tex>>=
34 library(xtable)
35 print(xtable(fit))
38 We can also plot some model diagnostics.
39 \begin{figure}
40   \centering
41 <<LinearModelDiagnosticPlots,fig=true>>=
42 oldpar <- par(no.readonly = TRUE)
43 par(mfcol = c(2, 2))
44 plot(fit, ask = FALSE)
45 par(oldpar)
47 \caption{Linear model diagnostic plots}
48 \end{figure}
51 \end{document}