make_amylase_long: Convert amylase columns from wide to long format

View source: R/long.R

make_amylase_longR Documentation

Convert amylase columns from wide to long format

Description

Convert amylase columns from wide to long format

Usage

make_amylase_long(df)

Arguments

df

a data.table

Details

The data contained in the 3 amylase columns of the targeted pancreatectomy dataset ("pan_amylase_pod1", "pan_amylase_pod230", and "damylase") are converted into a long format. This reduces the total number of columns from 3 to 2 and makes the data more intuitive.

If both "pan_amylase_pod1" and "pan_amylase_pod230" are columns in df, it will be broken into a long format with caseid as the ID variable for joining back to the main table. The amylase values from both "pan_amylase_pod1" and "pan_amylase_pod230" are placed in the "amylase" column". The POD on which this value was acquired (either 1 if from "pan_amylase_pod1" column or set equal to the value of the "damylase" column) is placed in the "pod" column.

Note that this does not alter the original columns.

Value

a data.table

Examples

x <- data.table::data.table(caseid = 1:30,
pan_amylase_pod1 = c(NA, sample(1:10000, 29)),
pan_amylase_pod230 = c(NA, sample(1000:10000, 29)),
damylase = c(NA, sample(2:30, 29)))

nsqipr:::make_amylase_long(x)


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