Skip to content

Commit

Permalink
Merge pull request #331 from billdenney/getGroups.PKNCAdata_derivation
Browse files Browse the repository at this point in the history
The creation of `getGroups.PKNCAdata` for use within PKNCA
  • Loading branch information
billdenney authored Nov 5, 2024
2 parents 6e33ed6 + da4b13c commit adbc3af
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ S3method(getDataName,PKNCAresults)
S3method(getDepVar,PKNCAconc)
S3method(getDepVar,PKNCAdose)
S3method(getGroups,PKNCAconc)
S3method(getGroups,PKNCAdata)
S3method(getGroups,PKNCAdose)
S3method(getGroups,PKNCAresults)
S3method(getIndepVar,PKNCAconc)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ the inclusion of IV NCA parameters and additional specifications of
the dosing including dose amount and route.

# PKNCA 0.11.0.9000

* PKNCA now contains a `getGroups.PKNCAdata` function to capture grouping columns.
* Duplicate data checks now account for excluded rows. So, if a row is
duplicated and all but one of the duplicated rows is excluded, it is not an
error. (#298)
Expand Down
12 changes: 12 additions & 0 deletions R/class-PKNCAdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,15 @@ print.PKNCAdata <- function(x, ...) {
summary.PKNCAdata <- function(object, ...) {
print.PKNCAdata(object, summarize=TRUE, ...)
}

#' Get the groups (right hand side after the `|` from a PKNCA
#' object).
#'
#' @rdname getGroups.PKNCAconc
#' @param object The object to extract the data from
#' @param ... Arguments passed to other getGroups functions
#' @returns A data frame with the (selected) group columns.
#' @export
getGroups.PKNCAdata <- function(object, ...) {
getGroups(as_PKNCAconc(object), ...)
}
12 changes: 10 additions & 2 deletions man/getGroups.PKNCAconc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions tests/testthat/test-class-PKNCAdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,17 @@ test_that("intervals may be a tibble", {
as.data.frame(pk.nca(mydata))
)
})

test_that("getGroups works", {
# Check that it works with grouping [contains only the grouping column(s)]
o_conc_group <- PKNCAconc(as.data.frame(datasets::Theoph), conc~Time|Subject)
data_group <- as.data.frame(datasets::Theoph)
expected_group <- data.frame(Subject = data_group$Subject)

expect_equal(getGroups.PKNCAdata(o_conc_group), expected_group)

# Check that it works without groupings as expected [empty]
o_conc_nongroup <- PKNCAconc(as.data.frame(datasets::Theoph)[datasets::Theoph$Subject == 1,], conc~Time)

expect_equal(names(getGroups.PKNCAdata(o_conc_nongroup)), character(0))
})

0 comments on commit adbc3af

Please sign in to comment.