% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/RcppExports.R
\name{actualstage3}
\alias{actualstage3}
\title{Calculate Actual Stage, Age, Stage-Pair, or Age-Stage Distributions}
\usage{
actualstage3(
  data,
  check_stage = TRUE,
  check_age = FALSE,
  historical = FALSE,
  year2 = NULL,
  indices = NULL,
  stagecol = NULL,
  agecol = NULL,
  remove_stage = NULL,
  t1_allow = NULL
)
}
\arguments{
\item{data}{A demographic dataset in hfv format.}

\item{check_stage}{A logical value indicating whether to assess frequencies
and proportions of stages. Defaults to \code{TRUE}.}

\item{check_age}{A logical value indicating whether to assess frequencies and
proportions of ages. Defaults to \code{FALSE}.}

\item{historical}{A logical value indicating whether the stage structure
should be ahistorical (\code{FALSE}) or historical (\code{TRUE}). Defaults to
\code{FALSE}.}

\item{year2}{A string value indicating the name of the variable coding for
monitoring occasion at time \emph{t}. Defaults to \code{"year2"}.}

\item{indices}{A vector of three strings, indicating the stage indices for
times \emph{t}+1, \emph{t}, and \emph{t}-1, respectively, in \code{data}.
Defaults to \code{c("stage3index", "stage2index", "stage1index")}.}

\item{stagecol}{A vector of three strings, indicating the stage name columns
for times \emph{t}+1, \emph{t}, and \emph{t}-1, respectively, in \code{data}.
Defaults to \code{stagecol = c("stage3", "stage2", "stage1")}.}

\item{agecol}{A single string indicating the age of individuals in time
\emph{t}. Defaults to \code{"obsage"}.}

\item{remove_stage}{A string vector indicating the names of stages to remove
from consideration. Defaults to \code{"NotAlive"}.}

\item{t1_allow}{A string vector indicating which stages to be removed should
be allowed in the stage at time \emph{t}-1 portion of historical stage
pairs, if \code{historical = TRUE}. Defaults to \code{"NotAlive"}. Can also
be set to \code{"none"}.}
}
\value{
A data frame with the following variables:
\item{rowid}{A string identifier term, equal to the monitoring occasion in
time \emph{t} and the stage index.}
\item{stageindex}{The stageframe index of the stage. Only output if
\code{check_stage = TRUE}.}
\item{stage}{The name of each stage, or \code{NA}. Only output if
\code{check_stage = TRUE}.}
\item{stage2}{The name of the stage in time \emph{t}. Only output if
\code{check_stage = TRUE}.}
\item{stage1}{The name of the stage in time \emph{t}-1, or \code{NA}. Only
output if \code{check_stage = TRUE}.}
\item{age}{The age at time \emph{t}. Only output if \code{check_age = TRUE}.}
\item{year2}{Monitoring occasion in time \emph{t}.}
\item{frequency}{The number of individuals in the respective stage and time.}
\item{actual_prop}{The proportion of individuals alive in time \emph{t} in
the respective stage.}
}
\description{
Function \code{actualstage3()} shows the frequencies and proportions of
each stage, stage pair, age-stage, or age in each year.
}
\section{Notes}{

This function produces frequencies and proportions of stages in hfv formatted
data using stage index variables rather than stage name variables, and so
requires the former. The latter is only required if the user wants to know
the associated stage names.

Frequencies and proportions will be calculated for all times, including the
last time, which is generally found in the \code{stage3} columns of the last
\code{year2} entry in object \code{data}. The default is to treat the
\code{year2} entry for that time as \code{max(year2) + 1}.

If \code{check_stage = TRUE} and \code{check_age = FALSE}, then this function
will assess frequencies and proportions of stages or historical stage-pairs.
If both \code{check_stage = TRUE} and \code{check_age = TRUE}, then this
function will assess frequencies and proportions of age-stages. If
\code{check_stage = FALSE} and \code{check_age = TRUE}, then the frequencies
and proportions of ages only will be assessed.

Note that no stageframe is required for this function to operate. Stage
names and their order are inferred directly from the object \code{data}.
}

\examples{
sizevector <- c(0, 0, 0, 0, 0, 0, 1, 3, 6, 11, 19.5)
stagevector <- c("SD", "P1", "P2", "P3", "SL", "D", "XSm", "Sm", "Md", "Lg",
  "XLg")
repvector <- c(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1)
obsvector <- c(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1)
matvector <- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)
immvector <- c(0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0)
propvector <- c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
indataset <- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)
binvec <- c(0, 0, 0, 0, 0, 0.5, 0.5, 1.5, 1.5, 3.5, 5)
comments <- c("Dormant seed", "1st yr protocorm", "2nd yr protocorm",
  "3rd yr protocorm", "Seedling", "Dormant adult",
  "Extra small adult (1 shoot)", "Small adult (2-4 shoots)",
  "Medium adult (5-7 shoots)", "Large adult (8-14 shoots)",
  "Extra large adult (>14 shoots)")
cypframe_raw <- sf_create(sizes = sizevector, stagenames = stagevector, 
  repstatus = repvector, obsstatus = obsvector, matstatus = matvector,
  propstatus = propvector, immstatus = immvector, indataset = indataset, 
  binhalfwidth = binvec, comments = comments)

cypraw_v1 <- verticalize3(data = cypdata, noyears = 6, firstyear = 2004, 
  patchidcol = "patch", individcol = "plantid", blocksize = 4,
  sizeacol = "Inf2.04", sizebcol = "Inf.04", sizeccol = "Veg.04",
  repstracol = "Inf.04", repstrbcol = "Inf2.04", fecacol = "Pod.04",
  stageassign = cypframe_raw, stagesize = "sizeadded", NAas0 = TRUE,
  NRasRep = TRUE, age_offset = 4)

all_stage_props_ah <- actualstage3(cypraw_v1)
all_stage_props_h <- actualstage3(cypraw_v1, historical = TRUE)
all_stage_props_h_NANotAllow <- actualstage3(cypraw_v1, historical = TRUE,
  t1_allow = "none")
all_stage_props_as <- actualstage3(cypraw_v1, check_age = TRUE)
all_age_props <- actualstage3(cypraw_v1, check_stage = FALSE,
  check_age = TRUE)

}
