\documentclass{article} \title{A Simple Sweave Example} \author{Mike Hammond} \begin{document} \maketitle Let's first display a simple statistical comparison and the code that produces it: <<>>= g <- read.table('gender.txt',header=T) gt <- with(g,tapply(age,gender,mean)) gt @ \noindent We can display the result of an \texttt R command in the actual text too. Here is the mean age of female sujects from the \texttt{gender.txt} dataset: $\Sexpr{round(mean(g$age[g$gender=='f']),3)}$. Now let's display a nice barplot of the result, without displaying the code that produces it. \begin{center} <>= barplot(gt,names.arg=c('female','male'),col=rainbow(15),ylab='age') @ \end{center} \end{document}