Learn R Programming

epiparameter (version 0.4.1)

as.function.epiparameter: as.function() method for <epiparameter> class

Description

Converts an <epiparameter> object to a distribution function (see epiparameter_distribution_functions), either probability density/mass function, (density), cumulative distribution function (cdf), random number generator (generate), or quantile (quantile).

Usage

# S3 method for epiparameter
as.function(x, func_type = c("density", "cdf", "generate", "quantile"), ...)

Value

A function object.

Arguments

x

An <epiparameter> object.

func_type

A single character string specifying which distribution to convert <epiparameter> object into. Default is "density". Other options are "cdf", "generate", or "quantile".

...

dots Extra arguments to be passed to the method.

Details

The function returned takes a single required argument x.

Examples

Run this code
ep <- epiparameter_db(single_epiparameter = TRUE)
# by default it will convert to a density function
f <- as.function(ep)
# use function
f(10)

f <- as.function(ep, func_type = "cdf")
f(10)

Run the code above in your browser using DataLab