Nadults: Calculate the harmonic mean of the total number of adults

View source: R/data_analysis.R

NadultsR Documentation

Calculate the harmonic mean of the total number of adults

Description

Nadults calculates, for several scenarios, the harmonic mean of the total number of adults between yr0 and yrt. These can be use to calculate Ne/N ratios where relevant.

Usage

Nadults(
  data,
  scenarios = "all",
  npops_noMeta = 1,
  appendMeta = FALSE,
  gen = 1,
  yr0 = 1,
  yrt = 2,
  save2disk = TRUE,
  fname = "Nadults",
  dir_out = "DataAnalysis"
)

Arguments

data

The second element (census_means) of the output from collate_yr

scenarios

A vector of scenario names for which Ne needs to be calculated, default: 'all'

npops_noMeta

The total number of populations excluding the metapopulation, default: 1

appendMeta

Whether to calculate data for the metapopulation, default: FALSE

gen

The generation time express in years

yr0

The time window to be considered (first and last year respectively)

yrt

The time window to be considered (first and last year respectively)

save2disk

Whether to save the output to disk, default: TRUE

fname

The name of the files where to save the output, defult: 'Nadults'

dir_out

The local path to store the output. Default: DataAnalysis

Details

yrt is adjusted by subtracting the number of years of the generation time (rounded to the nearest integer). In this way the user can provide the same yr0,yrt and gen to Nadults and Ne and these values are adjusted internally to correctly calculate the Ne/N ratios where relevant. If this behaviour is not desired, use gen=0.

Value

A data.table (data.frame if data.table is not loaded) with Nb values

Examples

# Using Pacioni et al. example data. See ?pac.yr for more details.
data(pac.yr)
NadultAll <- Nadults(data=pac.yr[[2]], scenarios='all', gen=2.54, yr0=50,
                     yrt=120, save2disk=FALSE)

carlopacioni/vortexR documentation built on May 6, 2022, 12:07 p.m.