make_pan_percdrainage_long: Convert pan_percdrainage column from wide to long format

View source: R/long.R

make_pan_percdrainage_longR Documentation

Convert pan_percdrainage column from wide to long format

Description

Convert pan_percdrainage column from wide to long format

Usage

make_pan_percdrainage_long(df)

Arguments

df

a data.table

Details

The data contained in the 4 "pan_percdrainage" columns created by make_pan_percdrainage_cols are converted into a long format.

If "pan_percdrainage" is a column in df, it will be broken into a long format with caseid as the ID variable for joining back to the main table. This is because the targeted pancreatectomy datasets input multiple values into a single "pan_percdrainage" column. For example, "Yes-other, Yes-bile, Yes-pus" may be an entry in the raw data set. This makes parsing for patients that had purulent percutaneous drainage at any point, for example, very difficult.

Note that this does not alter the "pan_percdrainage" column.

Value

a data.table

Examples

x <- data.table::data.table(caseid = 1:15,
pan_percdrainage = c("Yes-other", "Yes-bile", "Yes-pus", "Yes-amylase-rich fluid",
"Yes-amylase-rich fluid,Yes-pus", "Yes-bile,Yes-other", "Yes-amylase-rich fluid,Yes-pus,Yes-other",
"Yes-amylase-rich fluid,Yes-bile,Yes-other", "Yes-pus,Yes-bile", "Yes-pus,Yes-other",
"Yes-amylase-rich fluid,Yes-pus,Yes-bile", "Yes-amylase-rich fluid,Yes-other",
"Yes-amylase-rich fluid,Yes-pus,Yes-bile,Yes-other", "Yes-amylase-rich fluid,Yes-bile",
"Yes-pus,Yes-bile,Yes-other"))

nsqipr:::make_pan_percdrainage_cols(x)
nsqipr:::make_pan_percdrainage_long(x)


dylanrussellmd/nsqipr documentation built on Oct. 13, 2023, 11:01 a.m.