Skip to content

Commit

Permalink
testing and updating of documentation for getGroups.PKNCAdata()
Browse files Browse the repository at this point in the history
  • Loading branch information
DBartlettHP committed Nov 5, 2024
1 parent 32a6b03 commit 05bbc30
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 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
6 changes: 4 additions & 2 deletions R/class-PKNCAdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,10 @@ summary.PKNCAdata <- function(object, ...) {
print.PKNCAdata(object, summarize=TRUE, ...)
}

#' Get the groups
#'
#' 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.
Expand Down
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 05bbc30

Please sign in to comment.