\documentclass{article}

%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{unitedR}

\begin{document}

\author{David Schindler}

\title{Get started with \texttt{unitedR}}
\date{\today}
\maketitle


\section{Introduction}
This package provides functionality for simulation lineups and formations in United. It 
contains functions for finding the optimal formation to beat all expected lineups of opponents
in the game.
To install \texttt{unitedR} from CRAN, run
<<eval=FALSE>>=
install.packages("unitedR")
@
in your \texttt{R} command line. Afterwards the package can be installed as follows:
<<message=F>>=
library(unitedR)
@

\section{Working examples}
There are two main functions in the \texttt{unitedR} package:
\begin{itemize}
\item \texttt{formation}: define a valid lineup
\item \texttt{unitedSim}, \texttt{unitedSimOne}: compare a lineup to one or several other lineups.
\end{itemize}

In the following we define a \texttt{Home} lineup and two \texttt{Away} lineups. An unused sweeper has to be termed as 
\texttt{NA}. 
<<>>=
(home <- formation(10, NA, c(7,5,3), c(8,8), c(10,10,8,5,0)))
(away1 <- formation(5, 8, c(8,8,0,0), c(10,10), c(10,10,10),
 hardness = c(0,0,0,0,1)))
(away2 <- formation(10, 8, c(8,10), c(10,10), c(10,10,10,5,0),
 hardness = c(0,0,0,0,1), homeAdv = c(0,0,2,0,0)))
# unitedSim and unitedSimOne are similar in this particular case
unitedSim(home, away1)
unitedSim(home, away1, away2)
@


If you are using hardness it is recommended to simulate the red cards. An example is given in the following.

<<>>=
set.seed(123)
(home <- formation(10, NA, c(7,5,3), c(8,8), c(10,10,8,5,0),
                   hardness = c(0,0,4,2,1)))
(away1 <- formation(5, 8, c(8,8,0,0), c(10,10), c(10,10,10),
 hardness = c(0,0,0,0,1)))
(away2 <- formation(10, 8, c(8,10), c(10,10), c(10,10,10,5,0),
 hardness = c(0,0,0,0,8), homeAdv = c(0,0,2,0,0)))
# unitedSim and unitedSimOne are similar in this particular case
unitedSim(home, away1, r = 100)
unitedSim(home, away1, away2, r = 100)
@


Finally, if you are playing in total only with one or less points of hardness you can define formations directly. You 
don`t have to define the strength of the individual players like in the working examples above.

<<>>=
(home <- formation(10, NA, 14, 14, 42))
(away1 <- formation(5, 8, 10, 10, 30))
(away2 <- formation(10, 8, 16, 16, 30, homeAdv = c(0,0,2,0,0)))
# unitedSim and unitedSimOne are similar in this particular case
unitedSim(home, away1)
unitedSim(home, away1, away2)
@


\end{document}
