This allows you to add new variables to the Knowledge object,
even though it was frozen earlier by adding a data frame to the knowledge
constructor knowledge().
See also
Other knowledge functions:
+.Knowledge(),
add_exogenous(),
add_tier(),
add_to_tier(),
add_vars(),
as_bnlearn_knowledge(),
as_pcalg_constraints(),
as_tetrad_knowledge(),
convert_tiers_to_forbidden(),
deparse_knowledge(),
forbid_edge(),
get_tiers(),
knowledge(),
knowledge_to_caugi(),
remove_edge(),
remove_tiers(),
remove_vars(),
reorder_tiers(),
reposition_tier(),
require_edge(),
seq_tiers()
Examples
# unfreeze allows adding variables beyond the original data frame columns
data(tpc_example)
kn <- knowledge(tpc_example)
# this would error while frozen
try(add_vars(kn, "new_var"))
#> Error : Unknown variable(s): [new_var]
#> They are not present in the data frame provided to this Knowledge object.
# unfreeze and add the new variable successfully
kn <- unfreeze(kn)
kn <- add_vars(kn, "new_var")
print(kn)
#>
#> ── Knowledge object ────────────────────────────────────────────────────────────
#>
#> ── Variables ──
#>
#> var tier
#> <chr> <chr>
#> 1 child_x1 NA
#> 2 child_x2 NA
#> 3 oldage_x5 NA
#> 4 oldage_x6 NA
#> 5 youth_x3 NA
#> 6 youth_x4 NA
#> 7 new_var NA
