View source: R/plotEventDuration.R
plotEventDuration | R Documentation |
plotEventDuration
plotEventDuration(
eventDurations,
minCellCount = 0,
treatmentGroups = "both",
eventLines = NULL,
includeOverall = TRUE
)
eventDurations |
( |
minCellCount |
( |
treatmentGroups |
( |
eventLines |
( |
includeOverall |
( |
ggplot
ableToRun <- all(
require("CirceR", character.only = TRUE, quietly = TRUE),
require("CDMConnector", character.only = TRUE, quietly = TRUE),
require("TreatmentPatterns", character.only = TRUE, quietly = TRUE),
require("dplyr", character.only = TRUE, quietly = TRUE)
)
if (ableToRun) {
withr::local_envvar(
R_USER_CACHE_DIR = tempfile(),
EUNOMIA_DATA_FOLDER = Sys.getenv("EUNOMIA_DATA_FOLDER", unset = tempfile())
)
tryCatch({
if (Sys.getenv("skip_eunomia_download_test") != "TRUE") {
CDMConnector::downloadEunomiaData(overwrite = TRUE)
}
}, error = function(e) NA)
con <- DBI::dbConnect(duckdb::duckdb(), dbdir = eunomiaDir())
cdm <- cdmFromCon(con, cdmSchema = "main", writeSchema = "main")
cohortSet <- readCohortSet(
path = system.file(package = "TreatmentPatterns", "exampleCohorts")
)
cdm <- generateCohortSet(
cdm = cdm,
cohortSet = cohortSet,
name = "cohort_table"
)
cohorts <- cohortSet %>%
# Remove 'cohort' and 'json' columns
select(-"cohort", -"json") %>%
mutate(type = c("event", "event", "event", "event", "exit", "event", "event", "target")) %>%
rename(
cohortId = "cohort_definition_id",
cohortName = "cohort_name",
) %>%
select("cohortId", "cohortName", "type")
outputEnv <- computePathways(
cohorts = cohorts,
cohortTableName = "cohort_table",
cdm = cdm
)
results <- export(outputEnv)
plotEventDuration(
eventDurations = results$summary_event_duration,
minCellCount = 5,
treatmentGroups = "group",
eventLines = 1:4,
includeOverall = FALSE
)
Andromeda::close(outputEnv)
DBI::dbDisconnect(con, shutdown = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.