dparse: Parse Distributions Represented as Strings

View source: R/dparse.R

dparseR Documentation

Parse Distributions Represented as Strings

Description

Parse a custom string that represents an R6 distribution

Usage

dparse(toparse)

Arguments

toparse

(character(1))
String to parse, which should be in the format Distribution([params]), see examples.

Details

Transform a custom (user) input to a R6 object.

This function is specially useful when you expect a user input which should result in specific distribution. The distribution name must be the ShortName, ClassName or Alias listed in the package, which can be found with listDistributions().

Value

Returns an R6 Distribution

Examples

dparse("N()")
dparse("norm(0, sd = 2)")
# lower and upper case work
dparse("n(sd = 1, mean = 4)")
dparse("T(df = 4)")
dparse("cHiSq(df = 3)")
# be careful to escape strings properly
dparse("C(list('A', 'B'), c(0.5, 0.5))")
dparse("Cat(elements = c('A', 'B'), probs = c(0.5, 0.5))")

RaphaelS1/distr6 documentation built on Feb. 24, 2024, 9:14 p.m.