\documentclass[11pt,BCOR2mm,DIV18]{scrartcl}
\usepackage{lscape}

%%%%%%%%%%%%%%%%%%%%%
%Use for line wrapping in verbatim
\makeatletter
\def\@xobeysp{ }
\makeatother

\usepackage[Glenn]{fncychap}
% For floating figures
\usepackage{wrapfig}
% For fancy tables
\usepackage{booktabs}

% For symbols in T1 encoding.
\usepackage{textcomp}

\usepackage[colorinlistoftodos, textwidth=4cm, shadow, textsize=tiny]{todonotes}

\usepackage{amsmath,amsfonts,graphicx,comment,typearea,pifont}
\usepackage{xcomment,color, psfrag,enumerate,scrpage2,xspace,listings,wasysym, comment}
\usepackage{termcal}

\pagestyle{scrheadings}  
\setheadsepline{.4pt}
\ihead[]{\Sexpr{d['stud_id']}}
\chead[]{}
\ohead[]{\Sexpr{d['stud_name']}}
%\ifoot[]{\textit{Dr Colin Gillespie - c.gillespie@ncl.ac.uk}}
\cfoot[]{}
%\ofoot[]{MAS1343 - Practical 3}



% fourier for math | Palatino for rm | Helvetica for ss | Courier for tt
\renewcommand{\rmdefault}{ppl} % rm
\linespread{1.05}        % Palatino needs more leading
\usepackage[scaled=0.9]{helvet} % ss
\usepackage{courier} % tt
\usepackage{fourier} % math & rm
\normalfont
\usepackage[T1]{fontenc}
\graphicspath{{graphics/}}


\RequirePackage[unicode,hyperfootnotes=false]{hyperref}
\hypersetup{%3
  pdfborder = {0 0 0},
  bookmarksdepth = section,
  citecolor = DarkGreen,
  linkcolor = DarkBlue,
  urlcolor = DarkGreen,
}%
\usepackage{microtype}
\lstdefinelanguage{myR}
{
    language=R,
    otherkeywords={read.table, set.seed},
    deletekeywords={url,codes, t, Call, formula,Q, R, on,by,hat,is, col, set},            
    sensitive=true,
    morecomment=[l]{\#},
    morestring=[b]", 
    morestring=[b]',
    basicstyle =\ttfamily,
    keywordstyle=\bf\color{blue},
    showtabs=false,
    showstringspaces=false,
    literate= {~}{$\sim$}{2},
    numberstyle=\sffamily\scriptsize,
    stepnumber=2
  }
\lstset{language=myR}



\SweaveOpts{keep.source=TRUE}

\begin{document}

\section*{General comments}

\begin{itemize}
\item \Sexpr{sweaveCheckFilename(d)}
\item \Sexpr{sweaveCheckSource(d)}
\Sexpr{sweaveCheckVariables(d)}
\end{itemize}

\Sexpr{sweaveEndDocument(d)}


\subsection*{Question 1: MySD}
<<echo=False>>=
d1= d[["tests"]][["MySD"]][[1]]
@ 

\begin{itemize}
\item Function test: \Sexpr{sweaveGetFunctionCall(d1)}
  \begin{itemize}
  \item \Sexpr{sweaveDidFunctionRun(d1)}
  \Sexpr{sweaveDidFunctionWork(d1)}
  \end{itemize}
\end{itemize}

\subsection*{Question 2: MyDifference}
<<echo=False>>=
d1= d[["tests"]][["MyDifference"]][[1]]
@ 

\begin{itemize}
\item Function test: \Sexpr{sweaveGetFunctionCall(d1)}
  \begin{itemize}
  \item \Sexpr{sweaveDidFunctionRun(d1)}
  \Sexpr{sweaveDidFunctionWork(d1)}
  \end{itemize}
\end{itemize}



\subsection*{Question 3: MyMean2}
<<echo=False>>=
d1 = d[["tests"]][["MyMean2"]][[1]]
d2 = d[["tests"]][["MyMean2"]][[2]]
d3 = d[["tests"]][["MyMean2"]][[3]]
@ 

\begin{itemize}
\item Function test: \Sexpr{sweaveGetFunctionCall(d1)}
  \begin{itemize}
  \item \Sexpr{sweaveDidFunctionRun(d1)}
  \Sexpr{sweaveDidFunctionWork(d1)}
  \end{itemize}
\item Function test: \Sexpr{sweaveGetFunctionCall(d2)}
  \begin{itemize}
  \item \Sexpr{sweaveDidFunctionRun(d2)}
  \Sexpr{sweaveDidFunctionWork(d2)}
  \end{itemize}
\item Function test: \Sexpr{sweaveGetFunctionCall(d3)}
  \begin{itemize}
  \item \Sexpr{sweaveDidFunctionRun(d3)}
  \Sexpr{sweaveDidFunctionWork(d3)}
  \end{itemize}
\end{itemize}


\subsection*{Question 4: MyEven}
<<echo=False>>=
d1= d[["tests"]][["IsEven"]][[1]]
d2= d[["tests"]][["IsEven"]][[2]]
@ 

\begin{itemize}
\item Function test: \Sexpr{sweaveGetFunctionCall(d1)}
  \begin{itemize}
   \item \Sexpr{sweaveDidFunctionRun(d1)}
  \Sexpr{sweaveDidFunctionWork(d1)}
  \end{itemize}
  \item Function test: \Sexpr{sweaveGetFunctionCall(d2)}
  \begin{itemize}
  \item \Sexpr{sweaveDidFunctionRun(d2)}
  \Sexpr{sweaveDidFunctionWork(d2)}
  \end{itemize}
\end{itemize}


\subsection*{Question 5: MyMedian}

<<echo=False>>=
d1 = d[["tests"]][["MyMedian"]][[1]]
d2 = d[["tests"]][["MyMedian"]][[2]]
@ 

\begin{itemize}
\item Function test: \Sexpr{sweaveGetFunctionCall(d1)}
  \begin{itemize}
  \item \Sexpr{sweaveDidFunctionRun(d1)}
  \Sexpr{sweaveDidFunctionWork(d1)}
  \end{itemize}
\item Function test: \Sexpr{sweaveGetFunctionCall(d2)}
  \begin{itemize}
  \item \Sexpr{sweaveDidFunctionRun(d2)}
  \Sexpr{sweaveDidFunctionWork(d2)}
  \end{itemize}
\end{itemize}

\clearpage

\section*{Your code}

\small
\Sexpr{sweavePrintCode(d)}
\end{document}
