Learn R Programming

causalDisco (version 1.0.1)

seq_tiers: Generate a Bundle of Tier–Variable Formulas

Description

Quickly create a series of two‐sided formulas for use with tier(), where each formula maps a numeric tier index to a tidyselect specification that contains the placeholder i. The placeholder i is replaced by each element of tiers in turn, allowing you to write a single template rather than many nearly identical formulas.

Usage

seq_tiers(tiers, vars)

Value

A list of two‐sided formulas, each of class "tier_bundle". You can pass this list directly to tier() (which will expand it automatically).

Arguments

tiers

An integer vector of tier indices (each >= 1). These will appear as the left‐hand sides of the generated formulas.

vars

A tidyselect specification (unevaluated) that must contain the special placeholder i, either as the symbol i or inside a string like "…{i}…". For each value of i in tiers, that placeholder will be substituted and the resulting call used as the right‐hand side of a formula.

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(), unfreeze()

Examples

Run this code
# generate a bundle of tier formulas using a pattern with {i}
# here we create: 1 ~ matches("^child_x1$"), 2 ~ matches("^child_x2$")
data(tpc_example)

kn <- knowledge(
  tpc_example,
  tier(seq_tiers(1:2, matches("^child_x{i}$")))
)
print(kn)

Run the code above in your browser using DataLab