Skip to contents

This function calculates the overall treatment time (OTT) in days for a dataset containing EBRT start and end dates, and fraction dates. The OTT is computed from the EBRT start date to the last available treatment date, considering both the `ebrt_end_date_tdvh` and any fraction date columns.

Usage

emii_add_ott(data)

Arguments

data

A data frame containing treatment data. Must include `ebrt_start_date_tdvh`, `ebrt_end_date_tdvh`, and columns representing fraction dates with names containing both "fraction" and "date".

Value

A data frame with two additional columns:

  • `last_treatment_date`: The latest treatment date for each row.

  • `ott_days`: The overall treatment time in days (numeric).

Examples

library(dplyr)
library(lubridate)
#> 
#> Attaching package: ‘lubridate’
#> The following objects are masked from ‘package:base’:
#> 
#>     date, intersect, setdiff, union
emii <- tibble(
  embrace_id = c("AAR2001", "VIE2001"),
  ebrt_start_date_tdvh = as.POSIXct(c("2016-11-04", "2016-03-30")),
  ebrt_end_date_tdvh = as.POSIXct(c("2016-12-08", "2016-05-03")),
  fraction01date_tdvh = as.POSIXct(c("2016-12-19", "2016-05-10")),
  fraction02date_tdvh = as.POSIXct(c("2016-12-27", "2016-05-11"))
)
emii_add_ott(emii)
#> # A tibble: 2 × 7
#>   embrace_id ebrt_start_date_tdvh ebrt_end_date_tdvh  fraction01date_tdvh
#>   <chr>      <dttm>               <dttm>              <dttm>             
#> 1 AAR2001    2016-11-04 00:00:00  2016-12-08 00:00:00 2016-12-19 00:00:00
#> 2 VIE2001    2016-03-30 00:00:00  2016-05-03 00:00:00 2016-05-10 00:00:00
#> # ℹ 3 more variables: fraction02date_tdvh <dttm>, last_treatment_date <dttm>,
#> #   ott <dbl>