Filter infection IDs based on characteristics
Usage
epict_filter_ids(
obs,
min_uncensored_tests = 2,
min_days_with_uncensored = 2,
invert = FALSE
)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.censored: Logical, indicating if the Ct has been censored.
- min_uncensored_tests
Numeric defaults to 2. The minimum number of uncensored tests an ID must have in order to be included in the processed dataset.
- min_days_with_uncensored
Numeric defaults to 2. The minimum number of days tests per ID must span in order to be included in the processed dataset.
- invert
Logical, defaults to
FALSE. Should the filtering requirements be inverted. This switches from exluding to including and can be used for debugging and data exploration.
See also
Preprocessing functions
epict_check_obs(),
epict_check_raw_obs(),
epict_clean_factors(),
epict_drop_na_ct(),
epict_flag_spurious_obs(),
epict_make_time_rel_to_first_uncensored(),
epict_make_time_rel()
Examples
obs <- data.frame(
censored = c(TRUE, rep(FALSE, 3), TRUE, rep(FALSE, 4)),
id = c(1, 1, 1, 2, 3, 3, 4, 4, 4), t = c(0, 0, 1, 1, 1, 2, 1, 1, 1)
)
# Use defaults
epict_filter_ids(obs)
#> censored id t uncensored_tests days_with_uncensored
#> 1: TRUE 1 0 2 2
#> 2: FALSE 1 0 2 2
#> 3: FALSE 1 1 2 2
# Invert with defaults
epict_filter_ids(obs, invert = TRUE)
#> censored id t uncensored_tests days_with_uncensored
#> 1: FALSE 2 1 1 1
#> 2: TRUE 3 1 1 1
#> 3: FALSE 3 2 1 1
# Remove IDs with less than 3 tests
epict_filter_ids(obs, min_uncensored_tests = 3, min_days_with_uncensored = 1)
#> censored id t uncensored_tests days_with_uncensored
#> 1: FALSE 4 1 3 1
#> 2: FALSE 4 1 3 1
#> 3: FALSE 4 1 3 1
#' # Remove IDs with less than 3 tests - this will be all available data
epict_filter_ids(obs, min_days_with_uncensored = 3)
#> Empty data.table (0 rows and 5 cols): censored,id,t,uncensored_tests,days_with_uncensored