## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.height = 4.5, fig.width = 7, fig.align = "center" ) ## ----message = FALSE---------------------------------------------------------- library(summarySCI) data(hemoglobin_data) hb2 <- hemoglobin_data[hemoglobin_data$visit_nr == 2, ] hb2$hb_cat <- cut(hb2$hb, c(-Inf, 120, 140, Inf), labels = c("< 120", "120-140", "> 140")) ## ----message = FALSE, warning = FALSE----------------------------------------- res <- summarizeSCI(hb2, vars = c("hb", "hb_cat"), group = "Arm", labels = list(hb = "Hemoglobin (g/L)", hb_cat = "Hemoglobin category")) names(res$plots) res$table ## ----------------------------------------------------------------------------- res$plots$hb res$plots$hb_cat ## ----message = FALSE, warning = FALSE----------------------------------------- plots <- summarizeSCI(hb2, vars = c("hb", "hb_cat"), group = "Arm", type = "plot")$plots ## ----message = FALSE, warning = FALSE----------------------------------------- res_n <- summarizeSCI(hb2, vars = "hb_cat", group = "Arm", stat_cat = "n", missing_percent = FALSE) res_n$plots$hb_cat ## ----message = FALSE, warning = FALSE----------------------------------------- res_opt <- summarizeSCI(hb2, vars = c("hb", "hb_cat"), group = "Arm", type = "plot", plot_args = list(risk_table = TRUE, group_names_short = c("A", "B"))) res_opt$plots$hb ## ----message = FALSE, warning = FALSE----------------------------------------- res_note <- summarizeSCI(hb2, vars = "hb_cat", group = "Arm", type = "plot", plot_args = list(stat_footnote = TRUE)) res_note$plots$hb_cat ## ----eval = FALSE------------------------------------------------------------- # summarizeSCI(hb2, vars = c("hb", "hb_cat"), group = "Arm", # word_output = TRUE, file_path = "hemoglobin_table.docx") ## ----------------------------------------------------------------------------- out <- file.path(tempdir(), "figures") # one file per variable, named after it basename(save_plots(res, file_path = out)) # a single name prefixes the variable names basename(save_plots(res, file_name = "fig", file_path = out, format = "pdf")) # one name per plot, or a single plot basename(save_plots(res, file_name = c("hb_box", "hb_bars"), file_path = out)) basename(save_plots(res$plots$hb, file_name = "hemoglobin", file_path = out, width = 6, height = 4)) .