Skip to contents

Detect a within-case nesting variable by name pattern then structure

Usage

find_nest_var(data, exclude = character(0))

Arguments

data

Data frame.

exclude

Character vector of column names to skip (e.g., case, study, phase, time, outcome, piecewise terms).

Value

Column name (length-1 character), or NULL if no candidate is found.

Examples

d <- data.frame(
  case = rep("Ian", 8),
  behavior = rep(c("greet", "share"), 4),
  outcome = rnorm(8)
)
find_nest_var(d, exclude = "case")
#> [1] "behavior"