Description Usage Arguments Examples

View source: R/01-level-plot-function-new.r

This function produces a level plot showing the treatment effect size of pairwise subgroups and marginal subgroups defined by the categories of two covariates. Also, it prints out the minimum and maximum of the treatment effect size on the console so as to set an approapriate range for effect size on the colour strip. Note that there are two types of graphical display; whether show subgroup sample size by rectangles with different sizes (proportional to the ratio of sample size to the full size) or not. In addition, the function uses log odd ratio and log hazard ratio for displaying subgroup effect sizes in binary and survival data, respectively.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ```
plot_level(
dat,
covari.sel,
trt.sel,
resp.sel,
outcome.type,
ss.rect = FALSE,
range.strip = c(-6, 6),
n.brk = 30,
n.brk.axis = NULL,
font.size = c(15, 12, 0.8, 15, 0.6),
title = NULL,
strip = NULL,
effect = c("HR", "RMST"),
time = NULL,
show.overall = FALSE,
palette = "divergent",
col.power = 0.5,
grid.newpage = TRUE
)
``` |

`dat` |
a data set |

`covari.sel` |
a vector of indices of the two covariates |

`trt.sel` |
a covariate index which specifies the treatment code |

`resp.sel` |
a covariate index which specifies the response variable |

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

`ss.rect` |
a logical operator displaying the rectangles for subgroup sample sizes if TRUE |

`range.strip` |
a vector with two elements specifying the range of treatment effect size for display |

`n.brk` |
a number specifying the number of the points dividing the range of the argument "range.strip". |

`n.brk.axis` |
a number specifying the number of breakpoints dividing the axis of the argument "range.strip". |

`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 colour strip label; the third is for the category labels of the first and second covariates; the fourth is for the text in the middle cells; the fifth is for the unit label on the colour strip. |

`title` |
a string specifying the main title. |

`strip` |
a string specifying the title of the colour strip. |

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

`time` |
time for calculating the RMST |

`show.overall` |
logical. whether to show or not the overall treatment effect in the strip |

`palette` |
either "divergent" or "hcl" |

`col.power` |
to be used when palette = "hcl". see colorspace package for reference |

`grid.newpage` |
logical. If TRUE (default), the function calls grid::grid.newpage() to start from an empty page. |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | ```
# 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")
## 1.a Level plot -----------------------------------------------------------
plot_level(dat,
covari.sel = c(14,15),
trt.sel = 3,
resp.sel = c(1, 2),
outcome.type = "survival",
ss.rect = FALSE,
range.strip=c(-3, 3),
n.brk = 31,
n.brk.axis = 7,
font.size = c(14, 12, .8, 14, 0.7),
title = "Total sample size = 475",
strip = "Treatment effect size (log hazard ratio)",
effect = "HR",
show.overall = TRUE, palette = "hcl")
## 1.b Modified Level plot --------------------------------------------------
plot_level(dat,
covari.sel = c(14,15),
trt.sel = 3,
resp.sel = c(1, 2),
outcome.type = "survival",
ss.rect = TRUE,
range.strip=c(-3, 3),
n.brk = 31,
n.brk.axis = 7,
font.size = c(14, 12, .8, 14, 0.7),
title = paste0("Total sample size = ", nrow(dat)),
strip = "Treatment effect size (log hazard ratio)",
show.overall = TRUE, palette = "hcl")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.