make_amylase_long | R Documentation |
Convert amylase columns from wide to long format
make_amylase_long(df)
df |
a data.table |
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.
a data.table
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.