Extract the statistical summary generated by calcu
for continuous data
Source: R/calcu_med.R
bind_cut_cont.Rd
Parse the statistical summary generated by calcu
and generate the statistical
results in standard format
Arguments
- gt_table_body
result of
calcu
calculation.- aim_name
extract the specified column name.
- ifmiss
whether to retain the missing value in the output result,default is
FALSE
.- ppop
default is
NULL
.gt_table_body
come from a subset of the total population? If you need to calculate the statistics of the subset in the total population, please provide a total population.- iftest
default is
TRUE
.Provide the proportion of the subset of patients to the total number of people, similar to the statistics of the number of patients in biochemical tests.
Value
A structured data set.A structured dataset. Contains the average and
proportion of continuous variables, as well as the number and proportion of subsets after the classification of continuous variables.
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()
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)
## mutate multiple split variable columns
lab_wider_cut = mmc(lab_wider,lib_name_list,list_cut,digits=2)
## Add a missing data to fully demonstrate the function of the function
lab_wider_cut = lab_wider_cut %>%
rbind(.,
matrix(NA,nrow = 1,ncol =dim(lab_wider_cut)[2]) %>% data.frame() %>%
rename_at(vars(names(.)) ,~ names(lab_wider_cut)) ) %>%
mutate(patient_id = replace_na(patient_id, "test_id"))
## faster descriptive statistics.
data_lab_calcu <- calcu(lab_wider_cut[,-1],names(lab_wider)[-1])
## Statistical results of a single indicator
bind_cut_cont_test = bind_cut_cont(data_lab_calcu,"HbA1c")
## Statistical results of multiple indicators
purrr::map_df(lib_name_list,bind_cut_cont,
gt_table_body = data_lab_calcu,ppop=100)
}