\documentclass{article} \usepackage[margin=1in]{geometry} \usepackage{charter} \title{My First Sweave Document} \author{Roger Peng} \usepackage[noae]{/Users/rdpeng/install/R-patched/R.framework/Resources/share/texmf/Sweave} \begin{document} \maketitle Here is the ``airquality'' dataset that comes with R. <>= library(datasets) head(airquality) @ We can regress ozone on temperature, solar radiation, and wind. <>= fit <- lm(Ozone ~ Solar.R + Temp + Wind, data = airquality) library(xtable) xtab <- xtable(summary(fit), caption = "Regression of ozone on stuff") print(xtab) @ Here is a plot ozone vs. temperature. \begin{figure}[tbh] \centering <>= with(airquality, plot(Temp, Ozone)) @ \caption{Ozone and temperature} \label{fig:ozone} \end{figure} The ``airquality'' data frame has \Sexpr{nrow(airquality)} rows. <>= source("SweaveCache.R") cacheSweave("numbers.rda", quote( { numbers <- local({ Sys.sleep(5) rnorm(10) }) })) @ \end{document}