Skip to contents

Make time relative to first uncensored test per ID

Usage

epict_make_time_rel_to_first_uncensored(obs)

Arguments

obs

A data.frame with the following variables:

  • id: An integer vector uniquely identifying each infection.

  • t: Time of test relative to a baseline date.

  • onset_t: Time on onset relative to a baseline date (optional).

  • censored: Logical, indicating if the Ct has been censored.

Value

A data.table with times relative to the first uncensored test per ID.

Author

Sam Abbott

Examples

obs <- data.frame(
 id = c(rep(1, 3), rep(2, 4)), t = c(2, 3, 4, 1, 1, 2, 8), 
 onset_t = c(rep(2, 3), rep(4, 4)),
 censored = c(TRUE, FALSE, FALSE, TRUE, rep(FALSE, 3))
)

epict_make_time_rel_to_first_uncensored(obs)
#>    id t onset_t censored t_first_uncensored t_rel_uncensored
#> 1:  1 2       2     TRUE                  3               -1
#> 2:  1 3       2    FALSE                  3                0
#> 3:  1 4       2    FALSE                  3                1
#> 4:  2 1       4     TRUE                  1                0
#> 5:  2 1       4    FALSE                  1                0
#> 6:  2 2       4    FALSE                  1                1
#> 7:  2 8       4    FALSE                  1                7
#>    onset_t_rel_uncensored
#> 1:                     -1
#> 2:                     -1
#> 3:                     -1
#> 4:                      3
#> 5:                      3
#> 6:                      3
#> 7:                      3