action_levels: Compute Action Levels

View source: R/score_calculator.R

action_levelsR Documentation

Compute Action Levels

Description

Assigns monitoring or action levels based on individual percentile ranks using standard IDEFICS thresholds.

Usage

action_levels(
  df,
  sex = NULL,
  lvl_name = c("none", "monit", "action"),
  perc_level = c(0.9, 0.95),
  append = FALSE,
  filter = NULL
)

Arguments

df

A data frame containing percentile columns such as 'waist_percentile', 'sbp_percentile', 'hdl_percentile', etc.

sex

Character vector. Same length as 'age', 'height', and 'values'. Accepts "f" for female or "m" for male.

lvl_name

Character vector of level labels. Defaults to 'c("none", "monit", "action")'.

perc_level

Numeric vector of two percentiles used as cutoffs. Defaults to 'c(0.9, 0.95)' for 90th and 95th percentile.

append

Logical. If 'TRUE', appends action level columns to 'df'. If 'FALSE', returns only the computed levels.

filter

Character. Optional. Limits calculation to a specific domain: '"adiposity"', '"blood_pressure"', '"blood_lipids"', '"blood_glu_insu"', or '"overall"'.

Details

Action levels are derived using 'cut()' on percentile values. For example, a value > 95th percentile maps to '"action"'. HDL is reversed ('1 - hdl_percentile') since low HDL values are considered unhealthy.

Value

A list (or a modified data frame if 'append = TRUE') containing action level classifications for each domain.

Examples

df <- data.frame(waist_percentile = c(0.85, 0.96))
action_levels(df)

df <- data.frame(
  hdl_percentile = c(0.1,0.5),
  homa_percentile = c(0.4,0.9),
  trg_percentile = c(0.6,0.5),
  waist_percentile = c(0.9,0.99),
  sbp_percentile = c(0.8,0.01)
)
action_levels(df)

df <- data.frame(
  #sex = c("m", "m"),
  hdl_percentile = c(0.1,0.5),
  homa_percentile = c(0.4,0.9),
  trg_percentile = c(0.6,0.5),
  crp_percentile = c(0.95, 0.9),
  waist_percentile = c(0.9,0.99),
  sbp_percentile = c(0.8,0.01)
)
action_levels(df, sex = c("m", "m"))


pediatric.zcalc documentation built on Sept. 30, 2026, 5:13 p.m.