These functions are used to create parameters that consist of a single number. Parameters have a name, a value, a defined range of acceptable values, a default value, a class, and a shiny::shiny() widget for modifying them. If values are supplied to a parameter that are unacceptable then an error is thrown.

proportion_parameter(name, value)

binary_parameter(name, value)

integer_parameter(
  name,
  value,
  lower_limit = as.integer(-.Machine$integer.max),
  upper_limit = as.integer(.Machine$integer.max)
)

numeric_parameter(
  name,
  value,
  lower_limit = .Machine$double.xmin,
  upper_limit = .Machine$double.xmax
)

Arguments

name

character name of parameter.

value

integer or double value depending on the parameter.

lower_limit

integer or double value representing the smallest acceptable value for value. Defaults to the smallest possible number on the system.

upper_limit

integer or double value representing the largest acceptable value for value. Defaults to the largest possible number on the system.

Value

ScalarParameter object.

Details

Below is a list of parameter generating functions and a brief description of each.

proportion_parameter

A parameter that is a double and bounded between zero and one.

integer_parameter

A parameter that is a integer.

numeric_parameter

A parameter that is a double.

binary_parameter

A parameter that is restricted to integer values of zero or one.

Examples

# proportion parameter
p1 <- proportion_parameter('prop', 0.5) # create new object
print(p1) # print it
#> prop (0.5)
p1$get() # get value
#> [1] 0.5
p1$id # get id
#> id: 83111d5a-0878-4acf-85a4-4e89aced7154
p1$validate(5) # check if 5 is a validate input
p1$validate(0.1) # check if 0.1 is a validate input
p1$set(0.1) # change value to 0.1
print(p1)
#> prop (0.1)

# binary parameter
p2 <- binary_parameter('bin', 0) # create new object
print(p2) # print it
#> bin (0)
p2$get() # get value
#> [1] 0
p2$id # get id
#> id: 53bca62a-02ef-433d-8d5e-9b37f0556279
p2$validate(5) # check if 5 is a validate input
p2$validate(1L) # check if 1L is a validate input
p2$set(1L) # change value to 1L
print(p1) # print it again
#> prop (0.1)

# integer parameter
p3 <- integer_parameter('int', 5L) # create new object
print(p3) # print it
#> int (5)
p3$get() # get value
#> [1] 5
p3$id # get id
#> id: d3bb68f4-5d23-4d81-b17f-19a4ae6aa49a
p3$validate(5.6) # check if 5.6 is a validate input
p3$validate(2L) # check if 2L is a validate input
p3$set(2L) # change value to 2L
print(p3) # print it again
#> int (2)

# numeric parameter
p4 <- numeric_parameter('dbl', -7.6) # create new object
print(p4) # print it
#> dbl (-7.6)
p4$get() # get value
#> [1] -7.6
p4$id # get id
#> id: dc000f44-9f47-4c72-bd24-bbc7ff2f7429
p4$validate(NA) # check if NA is a validate input
p4$validate(8.9) # check if 8.9 is a validate input
p4$set(8.9) # change value to 8.9
print(p4) # print it again
#> dbl (8.9)

# numeric parameter with lower bounds
p5 <- numeric_parameter('bdbl', 6, lower_limit=0) # create new object
print(p5) # print it
#> bdbl (6)
p5$get() # get value
#> [1] 6
p5$id # get id
#> id: 38e23d65-e3ab-4c73-852b-9288c04fcb6a
p5$validate(-10) # check if -10 is a validate input
p5$validate(90) # check if 90 is a validate input
p5$set(90) # change value to 8.9
print(p5) # print it again
#> bdbl (90)