Plotting options

Introduction

This package provides functions to create an incidence or prevalence plot. There are a couple of options that can be specified when creating such a plot. In this vignette we are using the options in the plotIncidence function, however these same options can be specified in the plotPrevalence function.

cdm <- mockIncidencePrevalenceRef(
  sampleSize = 10000,
  outPre = 0.5
)
#> Warning: ! 17 column in person do not match expected column type:
#> • `person_id` is character but expected integer
#> • `gender_concept_id` is character but expected integer
#> • `year_of_birth` is numeric but expected integer
#> • `month_of_birth` is numeric but expected integer
#> • `day_of_birth` is numeric but expected integer
#> • `race_concept_id` is logical but expected integer
#> • `ethnicity_concept_id` is logical but expected integer
#> • `location_id` is character but expected integer
#> • `provider_id` is character but expected integer
#> • `care_site_id` is character but expected integer
#> • `person_source_value` is integer but expected character
#> • `gender_source_value` is integer but expected character
#> • `gender_source_concept_id` is character but expected integer
#> • `race_source_value` is integer but expected character
#> • `race_source_concept_id` is character but expected integer
#> • `ethnicity_source_value` is integer but expected character
#> • `ethnicity_source_concept_id` is character but expected integer
#> Warning: ! 3 column in observation_period do not match expected column type:
#> • `observation_period_id` is character but expected integer
#> • `person_id` is character but expected integer
#> • `period_type_concept_id` is logical but expected integer
#> Warning in validateCdmReference(cdm, soft = .softValidation): There are observation period end dates after the current date: 2024-09-30
#> ℹ The latest max observation period end date found is 2089-06-28
#> Warning: ! 1 column in target do not match expected column type:
#> • `subject_id` is character but expected integer
#> Warning: ! 1 column in outcome do not match expected column type:
#> • `subject_id` is character but expected integer
#> Warning: ! 17 column in person do not match expected column type:
#> • `person_id` is character but expected integer
#> • `gender_concept_id` is character but expected integer
#> • `year_of_birth` is numeric but expected integer
#> • `month_of_birth` is numeric but expected integer
#> • `day_of_birth` is numeric but expected integer
#> • `race_concept_id` is logical but expected integer
#> • `ethnicity_concept_id` is logical but expected integer
#> • `location_id` is character but expected integer
#> • `provider_id` is character but expected integer
#> • `care_site_id` is character but expected integer
#> • `person_source_value` is integer but expected character
#> • `gender_source_value` is integer but expected character
#> • `gender_source_concept_id` is character but expected integer
#> • `race_source_value` is integer but expected character
#> • `race_source_concept_id` is character but expected integer
#> • `ethnicity_source_value` is integer but expected character
#> • `ethnicity_source_concept_id` is character but expected integer
#> Warning: ! 3 column in observation_period do not match expected column type:
#> • `observation_period_id` is character but expected integer
#> • `person_id` is character but expected integer
#> • `period_type_concept_id` is logical but expected integer
#> Warning in validateCdmReference(cdm, soft = .softValidation): There are observation period end dates after the current date: 2024-09-30
#> ℹ The latest max observation period end date found is 2089-06-28
#> Warning: ! 1 column in target do not match expected column type:
#> • `subject_id` is character but expected integer
#> Warning: ! 1 column in outcome do not match expected column type:
#> • `subject_id` is character but expected integer

cdm <- generateDenominatorCohortSet(
  cdm = cdm, name = "denominator",
  cohortDateRange = c(as.Date("2008-01-01"), as.Date("2012-01-01")),
  sex = c("Male", "Female")
)
#> ℹ Creating denominator cohorts
#> Warning: ! 5 casted column in denominator (cohort_attrition) as do not match expected
#>   column type:
#> • `number_records` from numeric to integer
#> • `number_subjects` from numeric to integer
#> • `reason_id` from numeric to integer
#> • `excluded_records` from numeric to integer
#> • `excluded_subjects` from numeric to integer
#> Warning: ! 1 column in denominator do not match expected column type:
#> • `subject_id` is character but expected integer
#> ✔ Cohorts created in 0 min and 4 sec

inc <- estimateIncidence(
  cdm = cdm,
  denominatorTable = "denominator",
  outcomeTable = "outcome",
  interval = "years"
)
#> Getting incidence for analysis 1 of 2
#> Getting incidence for analysis 2 of 2
#> Overall time taken: 0 mins and 1 secs

Faceted plot

This is the default incidence plot where the plot has been faceted by sex.

plotIncidence(inc, facet = "denominator_sex")

Faceted plot - with lines

This is the previous plot where the dots are connected.

plotIncidence(inc, facet = "denominator_sex", ribbon = TRUE)

Faceted plot - with lines, no confidence interval

This is the previous plot where the dots are connected but no confidence interval is shown.

plotIncidence(inc, facet = "denominator_sex", ribbon = TRUE, 
              options = list('hideConfidenceInterval' = TRUE))

Faceted plot - with lines, no confidence interval, stacked, free scales

This is the previous plot where the subplots are shown on top of each other. The facetNcols variable defines the number of columns of the subplots. In addition we set facetScales as “free” so that the axis can vary by facet.

plotIncidence(inc, facet = "denominator_sex", ribbon = TRUE, 
              options = list('hideConfidenceInterval' = TRUE,
                             'facetNcols' = 1, 
                             'facetScales' = "free"))