Plot exposures and outcomes per person

plotPerPersonData(
  sccsData,
  outcomeId = NULL,
  exposureId = NULL,
  naivePeriod = 0,
  firstOutcomeOnly = FALSE,
  minAge = NULL,
  maxAge = NULL,
  fileName = NULL
)

Arguments

sccsData

An object of type sccsData as created using the getDbSccsData function.

outcomeId

The outcome to create the era data for. If not specified it is assumed to be the one outcome for which the data was loaded from the database.

exposureId

The exposure to create the era data for. If not specified it is assumed to be the one exposure for which the data was loaded from the database.

naivePeriod

The number of days at the start of a patient's observation period that should not be included in the risk calculations. Note that the naive period can be used to determine current covariate status right after the naive period, and whether an outcome is the first one.

firstOutcomeOnly

Whether only the first occurrence of an outcome should be considered.

minAge

Minimum age at which patient time will be included in the analysis. Note that information prior to the min age is still used to determine exposure status after the minimum age (e.g. when a prescription was started just prior to reaching the minimum age). Also, outcomes occurring before the minimum age is reached will be considered as prior outcomes when using first outcomes only. Age should be specified in years, but non-integer values are allowed. If not specified, no age restriction will be applied.

maxAge

Maximum age at which patient time will be included in the analysis. Age should be specified in years, but non-integer values are allowed. If not specified, no age restriction will be applied.

fileName

Name of the file where the plot should be saved, for example 'plot.png'. See the function ggsave in the ggplot2 package for supported file formats.

Value

A Ggplot object. Use the ggsave function to save to file.

Details

This plot shows the observation time (black), exposures (red), and outcomes (yellow) per person.

If parameters such as naivePeriod, minAge, and maxAge are provided, these will first be applied to curtail the observation period prior to plotting. Similarly, firstOutcomeOnly can be provided so subjects where the first outcome falls before the true observation start are removed before plotting.