\documentclass{article} \title{My First Sweave Doc} \author{Roger Peng} \SweaveOpts{echo=false} \begin{document} \maketitle \section{Loading the Data} Here I load the airquality dataset from the ``datasets'' package. A summary of the airquality data frame. <>= summary(airquality) @ The mean of ozone \Sexpr{mean(airquality$Ozone, na.rm=T)}. A histogram of the ozone variable. \begin{figure} \centering <>= hist(airquality$Ozone) @ \caption{Ozone histogram} \end{figure} Here's a regression of Ozone on other stuff. <>= library(xtable) fit <- lm(Ozone ~ Wind + Temp, data = airquality) xt <- xtable(fit) print(xt) @ Boxplot. <>= boxplot(airquality$Ozone) boxplot(airquality$Temp, add = TRUE) @ \end{document}