exitAtLastDate {CohortConstructor} | R Documentation |
Set cohort end date to the last of a set of column dates
Description
exitAtLastDate()
resets cohort end date based on a set of specified
column dates. The last date that occurs is chosen.
Usage
exitAtLastDate(
cohort,
dateColumns,
cohortId = NULL,
returnReason = TRUE,
name = tableName(cohort)
)
Arguments
cohort |
A cohort table in a cdm reference. |
dateColumns |
description |
cohortId |
IDs of the cohorts to modify. If NULL, all cohorts will be used; otherwise, only the specified cohorts will be modified, and the rest will remain unchanged. |
returnReason |
If TRUE it will return a column stating which column in
|
name |
Name of the new cohort with the restriction. |
Value
The cohort table.
Examples
library(CohortConstructor)
cdm <- mockCohortConstructor(tables = list(
"cohort" = dplyr::tibble(
cohort_definition_id = 1,
subject_id = c(1, 2, 3, 4),
cohort_start_date = as.Date(c("2000-06-03", "2000-01-01", "2015-01-15", "2000-12-09")),
cohort_end_date = as.Date(c("2001-09-01", "2001-01-12", "2015-02-15", "2002-12-09")),
date_1 = as.Date(c("2001-08-01", "2001-01-01", "2015-01-15", "2002-12-09")),
date_2 = as.Date(c("2001-08-01", NA, "2015-04-15", "2002-12-09"))
)
))
cdm$cohort |> exitAtLastDate(dateColumns = c("date_1", "date_2"))
[Package CohortConstructor version 0.2.1 Index]