Accessor & display methods for simpr_spec class

# S3 method for simpr_spec
print(x, ...)

new_simpr_spec()

is.simpr_spec(x)

Arguments

x

a simpr_spec object

...

ignored

Value

print.simpr_spec has no return value and is called for its side-effects.

new_simpr_spec returns an empty

simpr_spec object. is.simpr_spec returns a length-1 logical vector, TRUE or FALSE, which indicates whether an object is a

simpr_spec.

Details

Class simpr_spec is created by specify and/or define to specify the simulation variables, which is produced by generate. The print method provides an overview of the specification, including the conditions.

Examples

empty = new_simpr_spec()
print(empty)
#> $specify
#> NULL
#> 
#> $conditions
#> NULL
#> 
#> $meta_info
#> NULL
#> 
#> $include_calls
#> NULL
#> 

## Easiest to create a simpr_spec with specify
simple_spec = specify(a = ~ rbinom(n, size, prob))
print(simple_spec)
#> specify
#> --------------------------
#> $a
#> ~rbinom(n, size, prob)
#> attr(,"varnames")
#> [1] "a"
#> <environment: 0x7faf37331250>
#> 
#> 
#> $specify
#> NULL
#> 
#> $conditions
#> NULL
#> 
#> $meta_info
#> NULL
#> 
#> $include_calls
#> NULL
#> 

## Adding on define adds all possible combinations
## of conditions and more info in output.
defined_spec = specify(a = ~ rbinom(n, size, prob)) %>%
  define(n = c(10, 20),
         size = c(20, 40),
         prob = c(0.2, 0.4))
print(defined_spec)
#> specify
#> --------------------------
#> $a
#> ~rbinom(n, size, prob)
#> attr(,"varnames")
#> [1] "a"
#> <environment: 0x7faf37331250>
#> 
#> 
#> conditions
#> --------------------------
#> # A tibble: 8 × 3
#>       n  size  prob
#>   <dbl> <dbl> <dbl>
#> 1    10    20   0.2
#> 2    20    20   0.2
#> 3    10    40   0.2
#> 4    20    40   0.2
#> 5    10    20   0.4
#> 6    20    20   0.4
#> 7    10    40   0.4
#> 8    20    40   0.4
#> 
#> meta_info
#> --------------------------
#> 
#> $specify
#> NULL
#> 
#> $conditions
#> NULL
#> 
#> $meta_info
#> NULL
#> 
#> $include_calls
#> NULL
#>