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
)
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
#> ✔ 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
```

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

This is the previous plot where the dots are connected.

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

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"))
```

As we’ve used permanent tables for this example, we can drop these after running our analysis.

```
CDMConnector::listTables(attr(attr(cdm, "cdm_source"), "dbcon"))
#> [1] "denominator" "denominator_attrition" "denominator_codelist"
#> [4] "denominator_set" "observation_period" "outcome"
#> [7] "outcome_attrition" "outcome_codelist" "outcome_set"
#> [10] "person" "target" "target_attrition"
#> [13] "target_codelist" "target_set"
CDMConnector::dropTable(cdm = cdm, name = starts_with("denominator"))
CDMConnector::dropTable(cdm = cdm, name = starts_with("inc_participants_"))
CDMConnector::listTables(attr(attr(cdm, "cdm_source"), "dbcon"))
#> [1] "observation_period" "outcome" "outcome_attrition"
#> [4] "outcome_codelist" "outcome_set" "person"
#> [7] "target" "target_attrition" "target_codelist"
#> [10] "target_set"
```