View source: R/summariseTrend.R
| summariseTrend | R Documentation |
This function summarises temporal trends from OMOP CDM tables, considering only data within the observation period. It supports both event and episode tables and can report trends such as number of records, number of subjects, person-days, median age, and number of females.
summariseTrend(
cdm,
event = NULL,
episode = NULL,
output = "record",
interval = "overall",
ageGroup = NULL,
sex = FALSE,
inObservation = FALSE,
dateRange = NULL
)
cdm |
A |
event |
A character vector of OMOP table names to treat as event tables (uses only start date). |
episode |
A character vector of OMOP table names to treat as episode tables (uses start and end date). |
output |
A character vector indicating what to summarise.
Options include |
interval |
Time interval to stratify by. It can either be "years", "quarters", "months" or "overall". |
ageGroup |
A list of age groups to stratify the results by. Each element
represents a specific age range. You can give them specific names, e.g.
|
sex |
Logical; whether to stratify results by sex ( |
inObservation |
Logical. If |
dateRange |
A vector of two dates defining the desired study period.
If |
Event tables: Records are included if their start date falls within the study period. Each record contributes to the time interval containing the start date.
Episode tables: Records are included if their start or end date overlaps with the study period. Records are trimmed to the date range, and contribute to all overlapping time intervals between start and end dates.
A summarised_result object with the results.
library(OmopSketch)
library(omock)
library(dplyr)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
result <- summariseTrend(
cdm = cdm,
event = c("condition_occurrence", "drug_exposure"),
episode = "observation_period",
output = "person",
interval = "years",
ageGroup = list("<=20" = c(0, 20), ">20" = c(21, Inf)),
sex = TRUE,
dateRange = as.Date(c("1950-01-01", "2010-12-31"))
)
plotTrend(result = result, facet = sex ~ omop_table, colour = c("age_group"))
cdmDisconnect(cdm = cdm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.