Skip to contents

Usually each line of the patient's drug list is a separate drug name, while each row of the patient's diagnosis table is a combined string of multiple diagnoses. Therefore, it is necessary to develop a stream form to carry out efficient length-width conversion based on the patient's visit ID, so as to facilitate the descriptive statistics of the downstream process.

Usage

wider_clean(data, aim_select, ifunion = TRUE, split = ",")

Arguments

data

a dataframe

aim_select

three column names for analysis, including patient ID, visiting ID, and column names that need to change from length to width, the user is required to give the column name in the specified order.

ifunion

used to indicate whether the column that needs to be long to wide is a merged string. See more for details

split

default is ",".When the ifunion = TRUE,split provides a split point for data deduplication.

Value

A unique value for each patient, such as whether each patient has suffered from a disease or used a drug.

Details

ifunion parameter provides the user with an indication of whether the column used for length-width conversion is in the form of a merged string. When this colunm is a merged string (usually diagnosis table), it needs to be deduplicated based on the group ID expansion data and separate a collapsed column into multiple rows,see separate_rows().

Examples

if (FALSE) {
data(data_med)
diags = data_med$diag
aim_select = c("patient_id","visit_id","diag_union")
diag_wider = wider_clean(diags,aim_select)

prec = data_med$prec
aim_select = c("patient_id","visit_id","prec_name")
prec_wider= wider_clean(prec,aim_select,ifunion = FALSE)
}