plot_nightingale: Nightingale plot

Description Usage Arguments Examples

View source: R/30-nightingale_rose.R

Description

This function produces a nightingale plot with a binary response.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
plot_nightingale(
  dat,
  covari.sel,
  trt.sel = NULL,
  resp.sel,
  outcome.type = "binary",
  seq_by = 100,
  title = NULL,
  lab.y = NULL,
  strip = "Response",
  palette_colors = c("#faa8d2", "#80b1d3")
)

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".

seq_by

a number specifying the breaks in the y-axis

title

a string specifying the main title.

lab.y

a character value specifying the label of the y axis

strip

title for the legend

palette_colors

the colors for the graphics, a two character vector.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(dplyr)
dat <- prca
levels(dat$age_group) = c("Young","Middle-aged","Old")
levels(dat$weight_group)  = c("Low","Mid","High")
comb_levels = c("Young - Low", "Young - Mid", "Young - High",
                "Middle-aged - Low", "Middle-aged - Mid", "Middle-aged - High",
                "Old - Low", "Old - Mid", "Old - High")
dat %>%
  mutate(AgeWeight = factor(sprintf("%s - %s", age_group, weight_group),
                            levels = comb_levels))  %>%
  mutate(survival = factor(ifelse(survtime > 24 , "Yes", "No"),
                           levels = c("No", "Yes"))) %>%
  mutate(rx = factor(rx, labels = c("Control", "Treatment"))) -> dat

plot_nightingale(dat = dat, covari.sel = 16, resp.sel = 17,
                 strip = "2-year survival")
plot_nightingale(dat = dat, trt.sel = 3, covari.sel = 16,
                 resp.sel = 17,
                 seq_by = 50,
                 strip = "2-year survival")

Example output

Attaching package:dplyrThe following objects are masked frompackage:stats:

    filter, lag

The following objects are masked frompackage:base:

    intersect, setdiff, setequal, union

SubgrPlots documentation built on Jan. 29, 2020, 5:07 p.m.