Skip to contents

Normalizes specimen/sample type names and adds sample_category and a collapsed sterile_classification from the reference CSV file. Includes rule-based text cleaning and fuzzy matching for common shorthand and minor misspellings.

Usage

prep_standardize_specimens(
  data,
  specimen_col = "specimen_type",
  add_categories = TRUE
)

Arguments

data

Data frame with specimen column.

specimen_col

Character. Specimen column name. Default "specimen_type".

add_categories

Logical. Add sample_category and sterile_classification. sterile_classification is collapsed to Sterile, Non-Sterile, or Others/Ambiguous using specimen-specific rules for body-fluid, drain/device-associated, and unspecified samples. Default TRUE.

Value

Data frame with specimen_normalized, sample_category, and sterile_classification columns.