SubgrPlots (version 0.1.0)

plot_barchart: Barchart for subgroup effect size

Description

This function produces a bar chart showing the treatment effect size of pairwise subgroups defined by the categories of two covariates. Also, it prints out the minimum and maximum of the treatment effect size on the console. Note that each bar has a width which is proportional to the ratio of the corresponding sample size to the full size. In addition, the function uses log odd ratio and log hazard ratio for displaying subgroup effect sizes in binary and survival data, respectively.

Usage

plot_barchart(dat, covari.sel, trt.sel, resp.sel, outcome.type,
  font.size = c(15, 12, 10, 0.6), title = NULL, lab.y = NULL,
  effect = "RMST", time = NULL, decimals = 0)

Arguments

dat

a data set

covari.sel

a vector of indices of the two covariates

trt.sel

a covariate index specifying the treatment code

resp.sel

a covariate index specifying the response variable

outcome.type

a string specifying the type of the response variable, it can be "continuous", or "binary" or "survival".

font.size

a vector specifying the size of labels and text; the first element is for the main title; the second element is for the covariates labels and the y-axis label; the third is for the category labels; the forth is for the unit label of the y axis.

title

a string specifying the main title.

lab.y

a string specifying the y-axis label.

effect

either "HR" or "RMST". only when outcome.type = "survival"

time

time for calculating the RMST

decimals

decimal places for the axis

Examples

Run this code
# NOT RUN {
# # Load the data to be used
data(prca)
dat <- prca
levels(dat$age_group) = c("Young","Middle-aged","Old")
levels(dat$weight_group) = c("Low","Mid","High")
names(dat)[c(14,15)] = c("Age", "Weight")

## 4. Bar chart -----------------------------------------------------------
plot_barchart(dat,
              covari.sel = c(14,15),
              trt.sel = 3,
              resp.sel = c(1, 2),
              outcome.type = "survival",
              font.size = c(14, 12, 14, 0.75),
              lab.y = "Treatment effect size (RMST difference)")

# }

Run the code above in your browser using DataLab