adjustBirths: This function ensures that a vector of values will sum to a...

Description Usage Arguments Value Examples

View source: R/sourceSHAPE.R

Description

This function ensures that a vector of values will sum to a given number. It's implemented in certain growth forms (curently: constant and logistic)

Usage

1
2
adjustBirths(func_adjVector, func_sumTotal,
  func_roundValues = getOption("shape_track_asWhole"))

Arguments

func_adjVector

Vector of values which must sum to the func_sumTotal.

func_sumTotal

A single integer value which is to be the target summed value.

func_roundValues

Logical toggle to control in values must be rounded to integers.

Value

A vector of values adjusted to sum to a single value. These may have been forced to be rounded or could still contain decimals.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# In the event we're enforcing a vector to sum to a particular value, this function will
# force that vector to the sum and adjust proportionally to elements.  You can force values
# to become integers.
adjustBirths(func_adjVector = c(9,70,20), func_sumTotal = 100, func_roundValues = FALSE)
# When rounding, this is stochastic
replicate(10,adjustBirths(func_adjVector = c(9,70,20),
                          func_sumTotal = 100,
                          func_roundValues = TRUE))
# Same idea, different input vectors
adjustBirths(func_adjVector = c(10,75,20), func_sumTotal = 100, func_roundValues = FALSE)
replicate(10,adjustBirths(func_adjVector = c(10,75,20),
                             func_sumTotal = 100,
                             func_roundValues = TRUE))

rSHAPE documentation built on July 19, 2019, 5:05 p.m.

Related to adjustBirths in rSHAPE...