Learn R Programming

tooth (version 0.5.0)

pivot_to_long: Pivot wide tooth data to long format

Description

Helper to reshape wide-format data (one row per person-tooth, surfaces as separate columns) into the long format expected by calc_dmft().

Usage

pivot_to_long(
  data,
  id = "record_id",
  group = NULL,
  strata = NULL,
  lesion_suffix = "_les",
  filling_suffix = "_fil",
  activity_suffix = "_act",
  code_suffix = "_code"
)

Value

A long-format tibble.

Arguments

data

Wide data frame.

id

Person ID column name.

group

Optional grouping columns.

strata

Optional stratification columns.

lesion_suffix, filling_suffix, activity_suffix

Suffixes that identify the surface-level columns (default "_les", "_fil", "_act").

code_suffix

Suffix for tooth-level code columns (default "_code").

Details

Expects columns following the naming convention: {tooth}_{surface}_les, {tooth}_{surface}_fil, {tooth}_{surface}_act, and {tooth}_code for tooth-level status.