Skip to contents

Applies a function to every version of a history and binds the answers, one block per version. The function takes a model and returns a number (one column value), a named vector (one column per name) or a tibble (its rows).

Usage

vp_history_apply(history, f, ...)

Arguments

history

A history: the versions of a model, from vp_read_history() or vp_history(), oldest first.

f

A function of a model, such as vp_depth, or function(m) vp_gini(vp_feature_table(m)$required_by).

...

More arguments for f.

Value

A tibble with version and the columns of the answers.

Examples

gens <- c("miband1", "miband2", "miband3", "miband4", "miband6")
history <- vp_history(
  vp_example(paste0(gens, "_realized.uvl")),
  versions = gens,
  or_graph = TRUE
)
vp_history_apply(history, vp_depth)
#> # A tibble: 5 × 2
#>   version value
#>   <fct>   <int>
#> 1 miband1     0
#> 2 miband2     1
#> 3 miband3     3
#> 4 miband4     4
#> 5 miband6     5
vp_history_apply(
  history,
  function(m) vp_gini(vp_feature_table(m)$required_by)
)
#> # A tibble: 5 × 2
#>   version value
#>   <fct>   <dbl>
#> 1 miband1 0    
#> 2 miband2 0.625
#> 3 miband3 0.649
#> 4 miband4 0.676
#> 5 miband6 0.498