\documentclass[a4paper]{article}

\title{A \emph{brew} Test File}
\author{\emph{Jeffrey Horner}}

\usepackage{a4wide,graphicx}

\begin{document}

\maketitle

A simple example that will run in any \emph{R} engine \emph{(brew may work with S, but this is untested)}: The integers from 1 to
10 are
\begin{verbatim}
<%=format(1:10)%>
\end{verbatim}

We can also emulate a simple calculator \emph{(although the syntax is not as elegant as Sweave)}:
\begin{verbatim}
<% for (i in c('1+1','1+pi','1+pi','sin(pi/2)')) { -%>
> <%=i%>
<% print(eval(parse(text=i))) %>
<% } -%>
\end{verbatim}

Now we look at Gaussian data:

\begin{verbatim}
<%
library(stats)
x <- rnorm(20)
print(x)
print(t1 <- t.test(x))
%>
\end{verbatim}

Note that we can easily integrate some numbers into standard text: The
third element of vector \texttt{x} is <%=x[3]%>, the
$p$-value of the test is <%=format.pval(t1$p.value)%>. % $

Now we look at a summary of the famous iris data set, and we want to
see the commands in the code chunks \emph{(brew can't show you the code, so
don't look for it)}:

\begin{verbatim}
<% 
	library(datasets)
	data(iris) 
	print(summary(iris))
%>
\end{verbatim}

<%
	library(grDevices)
	library(graphics)
	postscript(file='brew-test-1-1.eps',
		width=5,height=5,paper='special',horizontal=FALSE)
	pairs(iris)
	dev.off()
%>
\begin{figure}[htbp]
  \begin{center}
\includegraphics{brew-test-1-1}
    \caption{Pairs plot of the iris data.}
  \end{center}
\end{figure}

<%
	postscript(file='brew-test-1-2.eps',
		width=5,height=5,paper='special',horizontal=FALSE)
	boxplot(Sepal.Length~Species, data=iris)
	dev.off()
%>
\begin{figure}[htbp]
  \begin{center}
\includegraphics{brew-test-1-2}
    \caption{Boxplot of sepal length grouped by species.}
  \end{center}
\end{figure}

\end{document}


