From cade3d051cc37bdced3fb3eef29c91afefed8d32 Mon Sep 17 00:00:00 2001 From: Adam Howes Date: Fri, 4 Oct 2024 13:38:34 +0100 Subject: [PATCH] Issue #359: Fix to `filter_obs_by_obs_time` function (#360) * Fix to filter_obs_by_obs_time function * Strange bug fix: reordering the columns makes a difference. Needs issue to fix * Remove "censored_obs_time" and "censored" columns and include "obs_time" as a column * Lint code --- R/observe.R | 5 ++--- tests/testthat/setup.R | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/R/observe.R b/R/observe.R index 59c751c92..96088313c 100644 --- a/R/observe.R +++ b/R/observe.R @@ -44,9 +44,8 @@ observe_process <- function(linelist) { filter_obs_by_obs_time <- function(linelist, obs_time) { linelist |> mutate( - obs_time = obs_time - .data$ptime, - censored_obs_time = .data$obs_time - .data$ptime_lwr, - censored = "interval" + obs_time = obs_time, + relative_obs_time = .data$obs_time - .data$ptime, ) |> filter(.data$stime_upr <= .data$obs_time) } diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index c3d6abed2..9ccab8c56 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -52,14 +52,16 @@ sim_obs_sex_m <- dplyr::filter(sim_obs_sex, sex == 0) |> dist = rlnorm, meanlog = meanlog_m, sdlog = sdlog_m - ) + ) |> + dplyr::select(case, ptime, delay, stime, sex) sim_obs_sex_f <- dplyr::filter(sim_obs_sex, sex == 1) |> simulate_secondary( dist = rlnorm, meanlog = meanlog_f, sdlog = sdlog_f - ) + ) |> + dplyr::select(case, ptime, delay, stime, sex) sim_obs_sex <- dplyr::bind_rows(sim_obs_sex_m, sim_obs_sex_f) |> observe_process() |>