\HeaderA{print.poplab}{Save to file a simulated population}{print.poplab}
\keyword{methods}{print.poplab}
\begin{Description}\relax
Save to file a simulated population in the folder specified 
in the function call. The name of the resulting file indicates
whether a baseline or an evolved population was saved.
\end{Description}
\begin{Usage}
\begin{verbatim}
## S3 method for class 'poplab':
print(x, option, year, folder, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an object returned by the 
\code{\LinkA{create.baseline.complete}{create.baseline.complete}}
or the \code{\LinkA{simped}{simped}} function
\item[\code{option}] 2 possible values \samp{"base"} or \samp{"current"} (see Details)
\item[\code{year}] last simulated year
\item[\code{folder}] folder (quoted) where the function saves the population. For example, 
it might be your R\_HOME/library/poplab/data/ directory, where R\_HOME is the location
where R is installed on your computer (see Examples below).
\item[\code{...}] further arguments passed to or from other methods
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{year} The population simulated only up to this calendar \code{year} 
is saved (i.e. individuals born after this \code{year} are excluded).

\code{option} Which simulated population should be saved to
file? \\
\samp{"base"} specifies a virtual baseline population (either an object
returned by the \code{\LinkA{create.baseline.complete}{create.baseline.complete}} function
or the first list component returned by the \code{\LinkA{simped}{simped}}
function). \\
\samp{"current"} specifies en evolved population simulated up to the calendar
year set by \code{year}; this population is the second list component returned
by the \code{\LinkA{simped}{simped}} function.
\end{Details}
\begin{Note}\relax
An error will be generated when attempting to save an object
returned by the \code{\LinkA{create.baseline.complete}{create.baseline.complete}}
function (the value of the \code{pop} argument) with \code{option}
set to \samp{"current"}.
\end{Note}
\begin{SeeAlso}\relax
\code{\LinkA{create.baseline.complete}{create.baseline.complete}}, \code{\LinkA{simped}{simped}},
\code{\LinkA{plot.poplab}{plot.poplab}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

## Not run: 
For these examples it is necessary to use the simped function
and assign the result to a variable called 'simpop'.
## End(Not run)

## simulate the population for the calendar period 1955-2002:
simpop <- 
simped(baseyear = 1955, basehealth = 0, basefamrisk = 2, 
sex.a = 2, endyear = 2002, healthy = 0, famrisk = 2, 
mortratio = 2, d.mod = "rr", fam.rel = "p", print.option = 
FALSE, population.fem = "populationfem.txt", population.male = 
"populationmale.txt", mortality.fem = "mortalityfem.txt", 
mortality.male = "mortalitymale.txt", fertility = 
"fertility.txt", incidence = "incidence.txt", seed = 
52482337, folder = system.file("data", package = "poplab"))

## save the population simulated up to the calendar year 1990
## (although the simped function simulated the population up
## to the year 2002); the name of the created file will be
## 'simpop_endYr_1990.txt'
print.poplab(simpop, "current", year = 1990, folder =
system.file("data", package = "poplab"))

## save the 1955 baseline population to a file named
## "base_pop_1955.txt"  
print.poplab(simpop, "base", year = 1955, folder =
system.file("data", package = "poplab"))

\end{ExampleCode}
\end{Examples}

