Skip to contents

Move a Tier Relative to Another in Knowledge

Usage

reposition_tier(kn, tier, before = NULL, after = NULL, by_index = FALSE)

Arguments

kn

A Knowledge object.

tier

The tier to move (label or index, honouring by_index).

before

Exactly one of these must be supplied and must identify another existing tier.

after

Exactly one of these must be supplied and must identify another existing tier.

by_index

If TRUE, treat order as the positions instead of labels. Defaults to FALSE.

Value

The updated Knowledge object.

Examples

# Move one tier relative to another
data(tpc_example)

kn <- knowledge(
  head(tpc_example),
  tier(
    child ~ starts_with("child"),
    youth ~ starts_with("youth"),
    oldage ~ starts_with("old")
  )
)

kn <- reorder_tiers(kn, c("youth", "child", "oldage"))
print(kn)
#> <Knowledge: 3 tiers | 6 vars>
#>   tier(youth): youth_x3, youth_x4
#>   tier(child): child_x1, child_x2
#>   tier(oldage): oldage_x5, oldage_x6