as_function: Convert <epiparameter> or 'NULL' to function

View source: R/utils.R

as_functionR Documentation

Convert ⁠<epiparameter>⁠ or NULL to function

Description

An extension to as.function(), particularly the epiparameter as.function S3 method, with the added feature that NULLs are converted into functions that generate a vector of NAs to behave equivalently to the generator functions output from as.function(..., func_type = "generate").

If a function is already passed to as_function it will be returned unchanged.

There is also input checking to error if input is not an ⁠<epiparameter>⁠, function (closure), or for onset-to-event distributions NULL.

Usage

as_function(x)

Arguments

x

A named list containing either ⁠<epiparameter>⁠, function or NULL. Named list elements are: "contact_distribution", "infectious_period", "onset_to_hosp", "onset_to_death", ⁠"onset_to_recovery".⁠

Value

A list of functions.


simulist documentation built on April 12, 2025, 1:34 a.m.