%
% NOTE -- ONLY EDIT THE .Rnw FILE!!!  The .tex file is
% likely to be overwritten.
%
\documentclass[11pt]{article}

\usepackage{times}
\usepackage{hyperref}

\usepackage[authoryear,round]{natbib}
\usepackage{times}
\usepackage{comment}

\textwidth=6.2in
\textheight=8.5in
%\parskip=.3cm
\oddsidemargin=.1in
\evensidemargin=.1in
\headheight=-.3in


\newlength{\smallfigwidth}
\setlength{\smallfigwidth}{6cm}

\newcommand{\scscst}{\scriptscriptstyle}
\newcommand{\scst}{\scriptstyle}

\newcommand{\Rfunction}[1]{{\texttt{#1}}}
\newcommand{\Robject}[1]{{\texttt{#1}}}
\newcommand{\Rpackage}[1]{{\textsf{#1}}}
\newcommand{\Rclass}[1]{{\textit{#1}}}

\newcommand{\MAT}[1]{{\bf #1}}
\newcommand{\VEC}[1]{{\bf #1}}

\newcommand{\Amat}{{\MAT{A}}}

%%notationally this is going to break
\newcommand{\Emat}{{\MAT{E}}}
\newcommand{\Xmat}{{\MAT{X}}}
\newcommand{\Xvec}{{\VEC{X}}}
\newcommand{\xvec}{{\VEC{x}}}


\newcommand{\Zvec}{{\VEC{Z}}}
\newcommand{\zvec}{{\VEC{z}}}

\newcommand{\calG}{\mbox{${\cal G}$}}

\bibliographystyle{plainnat}

\title{First test document for weaver}
\author{S. Falcon}

\usepackage{Sweave}
\begin{document}

\maketitle

\section{Introduction}

This document provides some simple test cases for caching chunks in an
Sweave document.

The first chunk is not cached and contains a simple call to
\Rfunction{rnorm}.  On consecutive builds, \Rcode{a} will have a
different value based on the current seed of the RNG.
\begin{Schunk}
\begin{Sinput}
> set.seed(123)
> a <- rnorm(5)
> a
\end{Sinput}
\begin{Soutput}
[1] -0.56047565 -0.23017749  1.55870831  0.07050839  0.12928774
\end{Soutput}
\end{Schunk}

Here we turn caching on.  Each expression in the chunk, in this case
every line, is cached separately.  Since the \Rcode{b} variable is in
a cached chunk, consecutive builds will have the same value.

\begin{Schunk}
\begin{Sinput}
> b <- rnorm(3)
> firstB <- b
> c <- runif(3)
> z <- b + c
> z
\end{Sinput}
\end{Schunk}

Since cache files are stored separately for each chunk, we can
duplicate an expression in a separate chunk and get a different
result.



\begin{Schunk}
\begin{Sinput}
> a
\end{Sinput}
\begin{Soutput}
[1] -0.56047565 -0.23017749  1.55870831  0.07050839  0.12928774
\end{Soutput}
\begin{Sinput}
> b
\end{Sinput}
\begin{Soutput}
[1] 1.6901844 0.5038124 2.5283366
\end{Soutput}
\begin{Sinput}
> c
\end{Sinput}
\begin{Soutput}
[1] 0.24608773 0.04205953 0.32792072
\end{Soutput}
\begin{Sinput}
> z
\end{Sinput}
\begin{Soutput}
[1]  1.9611527  0.5029757 -0.9371405
\end{Soutput}
\begin{Sinput}
> firstB
\end{Sinput}
\begin{Soutput}
[1]  1.7150650  0.4609162 -1.2650612
\end{Soutput}
\begin{Sinput}
> secondB
\end{Sinput}
\begin{Soutput}
[1] 1.6901844 0.5038124 2.5283366
\end{Soutput}
\begin{Sinput}
> thirdB
\end{Sinput}
\begin{Soutput}
[1] 1.6901844 0.5038124 2.5283366
\end{Soutput}
\end{Schunk}


\end{document}
