Skip to content

Commit

Permalink
Merge pull request #86 from InsightRX/RXR-1831
Browse files Browse the repository at this point in the history
Fix `n` and length of rate vector in regimens joined by t_dose_update
  • Loading branch information
karawoo authored Jan 8, 2024
2 parents 90cb3f6 + ed30f4b commit b892eca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions R/join_regimen.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ join_regimen <- function(
regimen1$t_inf <- c(regimen1$t_inf[keep], regimen2$t_inf)
regimen1$interval <- regimen2$interval
regimen1$type <- c(regimen1$type[keep], regimen2$type)
regimen1$rate <- c(regimen1$rate[keep], regimen2$rate)
regimen1$n <- length(regimen1$dose_amts)
return(regimen1)
}

Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/test_join_regimen.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,20 @@ test_that("join regimen works when no t_inf specified, e.g. oral or sc dosing",
expect_equal(reg$type, c("sc", "sc", "sc", "sc", "sc", "sc", "sc", "sc"))
expect_equal(reg$dose_amts, c(500, 500, 500, 400, 400, 400, 400, 400))
})

test_that("join_regimen with t_dose_update maintains correct rate length", {
reg1 <- new_regimen(
amt = 1,
times = c(0, 24),
type = "oral"
)
reg2 <- new_regimen(
amt = 2,
time = c(0, 24, 48),
type = "oral"
)
reg3 <- join_regimen(reg1, reg2, t_dose_update = 24)

expect_equal(length(reg3$rate), length(reg3$dose_times))
expect_equal(reg3$n, 4)
})

0 comments on commit b892eca

Please sign in to comment.