Mutate multiple split variable columns
Arguments
- data
a dataframe contain continuous type data column.
- lib_name_list
a series of continuous variables for classification, concatenated using character methods.
- list_cut
data split points used for grouping in multiple continuous variables,these split points need to be packed into a list.Warning:The order of checking
lib_name_list
andlist_cut
before starting analysis is the same.- openright
default
openright= FALSE
,the data interval is in the form of left opening and right closing,such as[1,2)
.Whenopenright= TRUE
, the data interval is in the form of left closing and right opening.- digits
defines the number of decimal places for the return label.
Examples
if (FALSE) {
data(data_med)
lab_wider = data_med$lab %>%
tr(.,c("test_date"),"dat") %>%
group_by(patient_id,lab_name) %>%
arrange(test_date) %>% slice_tail(n =1) %>% ungroup() %>%
select(patient_id,lab_name ,lab_va) %>%
tr(.,c("lab_va"),"num") %>%
spread(lab_name,lab_va) %>% distinct()
names(lab_wider)
HbA1c <- c(0,6.5,7.0,8.0,9.0,Inf)
TC <- c(0,5.2,6.2,Inf)
LDL <- c(0,3.4,4.1,Inf)
HDL <- c(0,1.0,Inf)
TG <- c(0,1.7,2.3,Inf)
WBC <- c(0,4,10,Inf)
## keep only the columns related to the analysis
lib_name_list <- names(lab_wider)[-1]
## this step need to adjust the order of list subsets in name_list order
list_cut <- list(HbA1c,HDL,LDL,TC,TG,WBC)
cut_dataframe = mmc(lab_wider,lib_name_list,list_cut,digits=2)
}