Skip to contents

Make time relative to first date of the test.

Usage

epict_make_time_rel(obs, baseline_date = min(obs$test_date, na.rm = TRUE))

Arguments

obs

A data.frame with the following variables:

  • test_date: Date of the test yielding a Ct value.

  • onset_date: Date of onset for each infection (optional).

baseline_date

A date to use as the baseline date for all other times in the dataset. By default this is the minimum test date in the dataset.

Value

A data.table with a t variable containing the numeric time in days since the baseline_date.

Author

Sam Abbott

Examples

obs <- data.frame(test_date = as.Date(c("2022-04-22", "2022-04-19")))

# Using default baseline date
epict_make_time_rel(obs)
#>     test_date t
#> 1: 2022-04-22 3
#> 2: 2022-04-19 0

# Using user specified baseline date
epict_make_time_rel(obs, baseline_date = as.Date("2022-04-01"))
#>     test_date  t
#> 1: 2022-04-22 21
#> 2: 2022-04-19 18

# When onsets are present
obs$onset_date <- obs$test_date
epict_make_time_rel(obs)
#>     test_date onset_date t onset_t
#> 1: 2022-04-22 2022-04-22 3       3
#> 2: 2022-04-19 2022-04-19 0       0