Skip to contents

It provides a ggplot of the temporal symmetry of two or more cohorts.

Usage

plotTemporalSymmetry(
  result,
  plotTitle = NULL,
  labs = c("Time (months)", "Individuals (N)"),
  xlim = c(-12, 12),
  colours = c("blue", "red"),
  scales = "free"
)

Arguments

result

Table output from summariseTemporalSymmetry.

plotTitle

Title of the plot, if NULL no title will be plotted.

labs

Axis labels for the plot.

xlim

Limits for the x axis of the plot.

colours

Colours for both parts of the plot, pre- and post- time 0.

scales

Whether to set free y scales for the facet wrap when there are multiple plots (i.e. each plot has its own scaled y axis) or set them equal for all. Only accepts "free" for the former and "fixed" for the latter.

Value

A plot for the temporal symmetry of cohorts.

Examples

# \donttest{
library(CohortSymmetry)
cdm <- mockCohortSymmetry()
#> Warning: ! 9 column in cdm_source do not match expected column type:
#>  `cdm_source_abbreviation` is logical but expected character
#>  `cdm_holder` is logical but expected character
#>  `source_description` is logical but expected character
#>  `source_documentation_reference` is logical but expected character
#>  `cdm_etl_reference` is logical but expected character
#>  `source_release_date` is logical but expected date
#>  `cdm_release_date` is logical but expected date
#>  `cdm_version` is numeric but expected character
#>  `vocabulary_version` is logical but expected character
#> Warning: ! 3 column in concept do not match expected column type:
#>  `concept_id` is numeric but expected integer
#>  `valid_start_date` is character but expected date
#>  `valid_end_date` is character but expected date
#> Warning: ! 1 column in vocabulary do not match expected column type:
#>  `vocabulary_concept_id` is numeric but expected integer
#> Warning: ! 5 column in concept_relationship do not match expected column type:
#>  `concept_id_1` is numeric but expected integer
#>  `concept_id_2` is numeric but expected integer
#>  `valid_start_date` is logical but expected date
#>  `valid_end_date` is logical but expected date
#>  `invalid_reason` is logical but expected character
#> Warning: ! 2 column in concept_synonym do not match expected column type:
#>  `concept_id` is numeric but expected integer
#>  `language_concept_id` is numeric but expected integer
#> Warning: ! 4 column in concept_ancestor do not match expected column type:
#>  `ancestor_concept_id` is numeric but expected integer
#>  `descendant_concept_id` is numeric but expected integer
#>  `min_levels_of_separation` is numeric but expected integer
#>  `max_levels_of_separation` is numeric but expected integer
#> Warning: ! 9 column in drug_strength do not match expected column type:
#>  `drug_concept_id` is numeric but expected integer
#>  `ingredient_concept_id` is numeric but expected integer
#>  `amount_unit_concept_id` is numeric but expected integer
#>  `numerator_unit_concept_id` is numeric but expected integer
#>  `denominator_value` is logical but expected numeric
#>  `denominator_unit_concept_id` is numeric but expected integer
#>  `box_size` is numeric but expected integer
#>  `valid_start_date` is character but expected date
#>  `valid_end_date` is character but expected date
#> Warning: There are observation period end dates after the current date: 2024-10-30
#>  The latest max observation period end date found is 2026-10-26
#> Warning: There are observation period end dates after the current date: 2024-10-30
#>  The latest max observation period end date found is 2026-10-26
cdm <- generateSequenceCohortSet(cdm = cdm,
                                 indexTable = "cohort_1",
                                 markerTable = "cohort_2",
                                 name = "joined_cohort")
temporal_symmetry <- summariseTemporalSymmetry(cohort = cdm$joined_cohort,
                                               minCellCount = 0)
#> Warning: `cdm_name` is present in both 'settings' and 'summarised_result'. This will be
#> an error in the next release.
#> Warning: `cdm_name` is present in both 'settings' and 'summarised_result'. This will be
#> an error in the next release.
plotTemporalSymmetry(result = temporal_symmetry)
#> Warning: `cdm_name` is present in both 'settings' and 'summarised_result'. This will be
#> an error in the next release.

CDMConnector::cdmDisconnect(cdm = cdm)
# }