blob: f8acd062c0b1bb2c9b0ab8f278e09414d7aced8e [file] [log] [blame]
\documentclass[11pt,a4paper]{article}
%% *** automatically switched by 'make' ( ./Makefile ) --- CARE!! in changing
\SweaveOpts{echo=FALSE,eval=FALSE,results=hide} % Exercise mode
%\SweaveOpts{echo=TRUE,eval=TRUE,results=verbatim} % Solution mode
%% other Sweave options
\SweaveOpts{engine=R, keep.source=TRUE, strip.white=true}
\newif\ifSolution
\Solutiontrue% if solution
\Solutionfalse%if exercise
%
\ifSolution\newcommand{\commentSol}[1]{#1}
\else \newcommand{\commentSol}[1]{}
\fi
\newcommand{\T}[1]{\texttt{#1}}
\begin{document}
<<preliminaries,echo=FALSE,results=hide>>=
options(width = 75, digits = 5, str=list(vec.len=2))
@
We work with the data set \T{airquality} which is part of R....
You can address it simply by \T{airquality}. Use \T{?airquality} to read about the
meaning of the variables contained in the dataset.
Get a summary of the data,
<<s-air-2,echo=TRUE,eval=TRUE>>=
summary(airquality)
@
\commentSol{The data set contains \Sexpr{nrow(airquality)} observations. The data is
complete for all but the first two variables \T{Ozone}, \T{Solar.R},
which contain \Sexpr{sum(is.na(airquality[,1]))} and
\Sexpr{sum(is.na(airquality[,2]))} missing values, respectively.
}
The above works in solution mode,
but in exercise mode, the $\backslash$Sexpr results are put out verbatim,
unfortunately using $\backslash$\verb|verb{bla bla{| and the left brace
\emph{really} messes up the $\backslash$commentSol\verb|{..}| command...
\end{document}