Skip to contents

Plot a continuous outcome for each combination of scheduled visit and study arm.

Usage

plot_outcome_by_visit_and_group(
  data,
  outcome_var,
  scheduled_timepoint_var,
  group_var,
  ...,
  geom = ggplot2::geom_boxplot,
  geom_args = list(na.rm = TRUE)
)

Arguments

data

(data frame)
The data frame that will be supplied to ggplot2::ggplot().

outcome_var

(numeric)
The continuous outcome variable to supply to the y argument of ggplot2::aes(). Whatever is supplied will be quoted and evaluated in the context of data.

scheduled_timepoint_var

(ordered)
The variable containing the scheduled timepoints to supply to the x argument of ggplot2::aes().. Whatever is supplied will be quoted and evaluated in the context of data.

group_var

(numeric)
The grouping variable (probably the study arm) to supply to the fill argument of ggplot2::aes().. Whatever is supplied will be quoted and evaluated in the context of data.

...

Forwarded onto ggplot2::ggplot(ggplot2::aes).

geom

(function)
The ggplot2 "geom" to use. Defaults to ggplot2::geom_boxplot().

geom_args

(list)
A list of arguments to supply to geom. Defaults to list(na.rm = TRUE).

Value

A ggplot object.

Examples


# Create a usable data set out of mmrm::fev_data
fev_mod <- mmrm::fev_data
fev_mod$VISITN <- fev_mod$VISITN * 10
fev_mod$time_cont <- fev_mod$VISITN + rnorm(nrow(fev_mod))
fev_mod$obs_visit_index <- round(fev_mod$time_cont)

plot_outcome_by_visit_and_group(
    data = fev_mod,
    outcome_var = FEV1,
    scheduled_timepoint_var = as.ordered(VISITN),
    group_var = ARMCD
)