Learn R Programming

LABTNSCPSS (version 1.0.2)

Create_data: Create and clean episode data

Description

Reads a CSV file, renames columns using a mapping, parses dates, cleans ICD codes, and writes a cleaned CSV to `cleaned_path`.

Usage

Create_data(input_file, col_mapping, cleaned_path = NULL)

Value

The `cleaned_path` (character string). Also invisibly returns the cleaned data.frame.

Arguments

input_file

Path to the input CSV.

col_mapping

Named character vector or list mapping standard names to user column names. Example: list(patient_id="Patient_id", ICD="diag_code", start_date="date_start", end_date="date_end", episode_id="episode_id")

cleaned_path

Path to write the cleaned CSV. If NULL, a default path in `tempdir()` is used.