diff --git a/NEWS.md b/NEWS.md index 43ca82d0..d39d115a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -74,6 +74,7 @@ the dosing including dose amount and route. for grouped joins, preserving left-table row order. Missing group validation ensures no rows are silently dropped. +* `PKNCAresults()` now includes `start` and `end` in `group_vars` ## Breaking changes diff --git a/R/class-PKNCAresults.R b/R/class-PKNCAresults.R index 41dc16b1..acfcd4ec 100644 --- a/R/class-PKNCAresults.R +++ b/R/class-PKNCAresults.R @@ -398,5 +398,5 @@ getGroups.PKNCAresults <- function(object, #' from the PKNCAconc object within #' @exportS3Method dplyr::group_vars group_vars.PKNCAresults <- function(x) { - group_vars.PKNCAconc(as_PKNCAconc(x)) + c("start","end",group_vars.PKNCAconc(as_PKNCAconc(x))) } diff --git a/tests/testthat/test-class-PKNCAresults.R b/tests/testthat/test-class-PKNCAresults.R index 87e19f66..effac1d8 100644 --- a/tests/testthat/test-class-PKNCAresults.R +++ b/tests/testthat/test-class-PKNCAresults.R @@ -421,14 +421,14 @@ test_that("group_vars.PKNCAresult", { o_data_group <- PKNCAdata(o_conc_group, intervals = data.frame(start = 0, end = 1, cmax = TRUE)) suppressMessages(o_nca_group <- pk.nca(o_data_group)) - expect_equal(dplyr::group_vars(o_nca_group), "Subject") + expect_equal(dplyr::group_vars(o_nca_group), c("start", "end", "Subject")) # Check that it works without groupings as expected [empty] o_conc_nongroup <- PKNCAconc(as.data.frame(datasets::Theoph)[datasets::Theoph$Subject == 1,], conc~Time) o_data_nogroup <- PKNCAdata(o_conc_nongroup, intervals = data.frame(start = 0, end = 1, cmax = TRUE)) suppressMessages(o_nca_nogroup <- pk.nca(o_data_nogroup)) - expect_equal(dplyr::group_vars(o_nca_nogroup), character(0)) + expect_equal(dplyr::group_vars(o_nca_nogroup), c("start","end")) }) test_that("as.data.frame.PKNCAresults can filter for only requested parameters", {