ScoreCalc: Compute IDEFICS and B4P Scores for Multiple Variables

View source: R/score_calculator.R

ScoreCalcR Documentation

Compute IDEFICS and B4P Scores for Multiple Variables

Description

Applies 'get_scores()' to multiple clinical biomarkers in a data frame and optionally returns MetS and cutoff levels.

Usage

ScoreCalc(
  df,
  return_input = FALSE,
  return_values = c("percentile", "z.score", "MetS", "cutoff.levels")
)

Arguments

df

A data frame with columns: 'sex', 'age', 'height', and observed values for any of the supported variables: 'bmi', 'glu', 'hdl', 'height', 'homa', 'insu', 'trg', 'waist', 'sbp', 'dbp', 'crp'.

Variables must be supplied using the units of the corresponding reference model:

  • 'age': years

  • 'height': cm

  • 'waist': cm

  • 'bmi': kg/m^2

  • 'glu': mg/dL

  • 'insu': \muIU/mL

  • 'homa': HOMA-IR (dimensionless)

  • 'hdl': mg/dL

  • 'trg': mg/dL

  • 'sbp', 'dbp': mmHg

  • 'crp': mg/L

'height' is required for the height-dependent blood-pressure models ('sbp' and 'dbp').

return_input

Logical. If 'TRUE', includes original input columns in the result. Defaults to 'FALSE'.

return_values

Character vector. Specifies which scores to compute. Options include '"percentile"', '"z.score"', '"MetS"', and '"cutoff.levels"'.

Details

The function applies 'get_scores()' to each recognized variable in the input and combines the results. If '"MetS"' is requested, a Metabolic Syndrome score is computed and optionally transformed to percentile ranks/z-scores.

Value

A data frame with score columns named as '<variable>_percentile', '<variable>_z.score', etc. Includes additional columns like 'MetS' or cutoff levels if requested.

Examples

df <- data.frame(
  sex = c("f", "m"),
  age = c(8, 15),
  height = c(120, 125),
  waist = c(55, 60),
  homa = c(1.2, 1.4),
  sbp = c(100, 105),
  dbp = c(65, 70),
  trg = c(80, 90),  # mg/dL
  crp = c(6, 2),    # mg/L
  hdl = c(50, 45)   # mg/dL
)

ScoreCalc(df, return_values = c("percentile", "cutoff.levels"))
# for the 15 year old male everything except CRP is NA (outside IDEFICS age range)


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