Skip to contents

This function search for date columns in every tables and returns the latest date for each patient with the variable it comes from. Useful in survival analysis to get the right censoring time.

Usage

lastnews_table(
  except = NULL,
  with_ties = FALSE,
  numeric_id = TRUE,
  warn_if_future = TRUE
)

Arguments

except

the datasets/columns that should not be searched. Example: a scheduled visit for which the patient may have died before attending should not be considered.

with_ties

in case of tie, whether to return the first origin (FALSE) or all the origins that share this tie (TRUE).

numeric_id

set to FALSE if the patient ID column is not numeric

warn_if_future

whether to show a warning about dates that are after the extraction date

Value

a dataframe

Examples

tm = edc_example_plot()
#> Warning: Option "edc_lookup" has been overwritten.
load_list(tm)
lastnews_table()
#> Error in map2(.x, vec_index(.x), .f, ...):  In index: 1.
#>  With name: db0.
#> Caused by error in `mutate()`:
#>  In argument: `label = unlist(get_label(.x)[name])`.
#> Caused by error in `map2()`:
#> ! could not find function "map2"
lastnews_table(except="db3")
#> Error in map2(.x, vec_index(.x), .f, ...):  In index: 1.
#>  With name: db0.
#> Caused by error in `mutate()`:
#>  In argument: `label = unlist(get_label(.x)[name])`.
#> Caused by error in `map2()`:
#> ! could not find function "map2"
lastnews_table(except="db3$date9")
#> Error in map2(.x, vec_index(.x), .f, ...):  In index: 1.
#>  With name: db0.
#> Caused by error in `mutate()`:
#>  In argument: `label = unlist(get_label(.x)[name])`.
#> Caused by error in `map2()`:
#> ! could not find function "map2"