Skip to contents

Adds a logical column indicating whether each row's age falls within the specified range (inclusive on both ends).

Usage

skeleton_eligible_age_range(
  dt,
  age_var,
  min_age,
  max_age,
  col_name = "eligible_age"
)

Arguments

dt

A data.table with the specified age variable.

age_var

Character. Name of the column containing continuous age.

min_age

Numeric. Minimum eligible age (inclusive).

max_age

Numeric. Maximum eligible age (inclusive).

col_name

Character. Name of the eligibility column to create. Default: "eligible_age".

Value

The input data.table (invisibly), modified by reference with the new eligibility column.

Examples

if (FALSE) { # \dontrun{
temp |>
  skeleton_eligible_age_range("rd_age_continuous", min_age = 50, max_age = 60)
} # }