
Generate a custom ggplot2 from a summarised_result object generated with summariseTreatment function.
Source:R/plots.R
plotTreatment.RdGenerate a custom ggplot2 from a summarised_result object generated with summariseTreatment function.
Usage
plotTreatment(
result,
x = "variable_level",
position = "stack",
facet = cdm_name + cohort_name ~ window_name,
colour = "variable_level",
style = "default"
)Arguments
- result
A summarised_result object.
- x
Variable to plot on x-axis
- position
Position of bars, can be either
dodgeorstack- facet
Columns to facet by. See options with
availablePlotColumns(result). Formula is also allowed to specify rows and columns.- colour
Columns to color by. See options with
availablePlotColumns(result).- style
Which style to apply to the plot, options are: "default", "darwin" and NULL (default ggplot style). Customised styles can be achieved by modifying the returned ggplot object.
Examples
if (FALSE) { # \dontrun{
library(DrugUtilisation)
cdm <- mockDrugUtilisation()
result <- cdm$cohort1 |>
summariseTreatment(
treatmentCohortName = "cohort2",
window = list(c(0, 30), c(31, 365))
)
plotTreatment(result)
plotTreatment(result, x = "cohort_name", facet = "window_name")
} # }