Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: vpc
Title: Create Visual Predictive Checks
Version: 1.3.6
Date: 2026-11-12
Version: 1.3.7
Date: 2026-11-14
Authors@R:
c(
person("Ron", "Keizer", email="ron@insight-rx.com", role=c("aut", "cre")),
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# vpc 1.3.7
- `vpc_tte()` with `rtte = TRUE` and `rtte_calc_diff = FALSE` or
`rtte_conditional = FALSE` no longer fails with "`time` must be a vector,
not a function" when the data have no column named `t` (#128). Censoring
marks are now placed at the original (absolute) time, stored internally
before any conversion to relative times.

# vpc 1.3.6
- Bins can now be determined per stratum (#11). With `bin_by_strata = TRUE` in
`vpc()` and `vpc_cens()`, automatic binning methods are applied to the data
Expand Down
5 changes: 5 additions & 0 deletions R/format_vpc_input_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ format_vpc_input_data_tte <- function(dat, cols, stratify, rtte, rtte_calc_diff,
dat[dat$cens == 1,]$dv <- 0
}
dat$time <- as.num(dat$idv)
if (rtte) {
# keep the original (absolute) time, used e.g. for plotting censoring
# marks when times are recalculated to relative times between events
dat$time_abs <- dat$time
}
if (what == "observed") {
# set sim to simplify code below
dat$sim <- 1
Expand Down
2 changes: 1 addition & 1 deletion R/vpc_tte.R
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ vpc_tte <- function(sim = NULL,
if(rtte) {
if(!rtte_conditional || !rtte_calc_diff) {
cens_dat <- cens_dat %>%
dplyr::mutate(time = t)
dplyr::mutate(time = .data$time_abs)
}
}
cens_dat <- cens_dat %>%
Expand Down
26 changes: 26 additions & 0 deletions tests/testthat/test-vpc_tte.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,29 @@ test_that("vpc_tte() keeps positional argument order (ci_sim appended last)", {
expect_s3_class(pl, "ggplot")
expect_equal(pl$labels$x, "Positional time label")
})

test_that("vpc_tte(rtte = TRUE) works without a `t` column (#128)", {
obs <- data.frame(id = rep(1:2, each = 2), time = c(3, 10, 4, 8), dv = c(1, 0, 1, 0))
sim <- rbind(cbind(obs, sim = 1), cbind(obs, sim = 2))
for (args in list(
list(rtte_calc_diff = FALSE, rtte_conditional = TRUE),
list(rtte_calc_diff = TRUE, rtte_conditional = FALSE),
list(rtte_calc_diff = FALSE, rtte_conditional = FALSE)
)) {
db <- suppressWarnings(
vpc_tte(sim = sim, obs = obs, rtte = TRUE,
rtte_calc_diff = args$rtte_calc_diff,
rtte_conditional = args$rtte_conditional,
sim_cols = list(sim = "sim"), vpcdb = TRUE)
)
# censoring marks at the original (absolute) times
expect_equal(sort(db$cens_dat$time), c(8, 10))
pl <- suppressWarnings(
vpc_tte(sim = sim, obs = obs, rtte = TRUE,
rtte_calc_diff = args$rtte_calc_diff,
rtte_conditional = args$rtte_conditional,
sim_cols = list(sim = "sim"))
)
expect_s3_class(pl, "ggplot")
}
})
Loading