Skip to content
Open
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
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ S3method(full_join,PKNCAresults)
S3method(getDataName,PKNCAconc)
S3method(getDataName,PKNCAdose)
S3method(getDataName,PKNCAresults)
S3method(getDataName,default)
S3method(getDepVar,PKNCAconc)
S3method(getDepVar,PKNCAdose)
S3method(getGroups,PKNCAconc)
Expand Down
10 changes: 5 additions & 5 deletions R/001-add.interval.col.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ add.interval.col <- function(name,
assign("interval.cols", current, envir=.PKNCAEnv)
}

#' Sort the interval columns by dependencies.
#'
#' Columns are always to the right of columns that they depend on.
sort.interval.cols <- function() {
# Sort the interval columns by dependencies.
#
# Columns are always to the right of columns that they depend on.
sort_interval_cols <- function() {
current <- get("interval.cols", envir=.PKNCAEnv)
# Only sort if necessary
sort_order <- get0("interval.cols_sorted", envir=.PKNCAEnv)
Expand Down Expand Up @@ -232,7 +232,7 @@ sort.interval.cols <- function() {
#' @family Interval specifications
#' @export
get.interval.cols <- function() {
sort.interval.cols()
sort_interval_cols()
get("interval.cols", envir=.PKNCAEnv)
}

Expand Down
5 changes: 2 additions & 3 deletions R/AIC.list.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' columns for degrees of freedom (`df`) and `AIC`. If `assess.best` is true,
#' then there will be another column `isBest`.
#' @noRd
AIC.list <- function(object, ..., assess.best=TRUE) {
AIC_list <- function(object, ..., assess.best=TRUE) {
allAICs <-
lapply(object, FUN=function(subobject, ...) {
# Return the AIC of the new model relative to the reference model
Expand Down Expand Up @@ -63,11 +63,10 @@ AIC.list <- function(object, ..., assess.best=TRUE) {
#' Extract the best model from a list of models using the AIC.
#'
#' @param object the list of models
#' @param \dots Parameters passed to AIC.list
#' @param \dots Parameters passed to AIC_list
#' @returns The model which is assessed as best. If more than one are equal,
#' the first is chosen.
#' @export
get.best.model <- function(object, ...) {
object[stats::AIC(object, ...)$isBest %in% "Best Model"][[1]]
}

1 change: 1 addition & 0 deletions R/class-general.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ getDataName <- function(object) {
}

#' @describeIn getDataName If no data name exists, returns NULL.
#' @export
getDataName.default <- function(object) {
NULL
}
Expand Down
2 changes: 1 addition & 1 deletion R/tss.monoexponential.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pk.tss.monoexponential.population <- function(data,
}
}
# Find the best model of the set and return the output from that one.
all.model.summary <- AIC.list(lapply(models, function(x) x$model))
all.model.summary <- AIC_list(lapply(models, function(x) x$model))
rownames(all.model.summary) <-
vapply(
X = models,
Expand Down
8 changes: 0 additions & 8 deletions coverage_check.R

This file was deleted.

14 changes: 7 additions & 7 deletions man/filter.PKNCAresults.Rd

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

2 changes: 1 addition & 1 deletion man/get.best.model.Rd

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

14 changes: 9 additions & 5 deletions man/group_by.PKNCAresults.Rd

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

11 changes: 0 additions & 11 deletions man/sort.interval.cols.Rd

This file was deleted.

14 changes: 7 additions & 7 deletions tests/testthat/test-001-add.interval.col.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test_that("add.interval.col", {
regexp="FUN must be a character string or NA",
info="interval column function must be a character string or NA"
)

expect_error(
add.interval.col(name="a", FUN=NA, datatype="interval", desc="test addition"),
regexp='argument "unit_type" is missing, with no default'
Expand All @@ -33,7 +33,7 @@ test_that("add.interval.col", {
add.interval.col(name="a", FUN=NA, unit_type="foo", datatype="interval", desc="test addition"),
regexp="should be one of .*inverse_time"
)

# pretty_name checks
expect_error(
add.interval.col(name="a", FUN=NA, unit_type="conc", pretty_name=1:2, datatype="interval", desc=1),
Expand All @@ -47,13 +47,13 @@ test_that("add.interval.col", {
add.interval.col(name="a", FUN=NA, unit_type="conc", pretty_name="", datatype="interval", desc=1),
regexp="pretty_name must not be an empty string"
)

expect_error(
add.interval.col(name="a", FUN=NA, unit_type="conc", pretty_name="a", datatype="individual"),
regexp="Only the 'interval' datatype is currently supported.",
info="interval column datatype must be 'interval'"
)

expect_error(
add.interval.col(name="a", FUN=NA, unit_type="conc", pretty_name="a", datatype="interval", desc=1:2),
regexp="desc must have length == 1",
Expand All @@ -69,7 +69,7 @@ test_that("add.interval.col", {
regexp="'depends' must be NULL or a character vector",
info="depends column must be a NULL or a character string"
)

expect_error(
add.interval.col(name="a", FUN="this function does not exist", unit_type="conc", pretty_name="foo", datatype="interval", desc="test addition"),
regexp="The function named '.*' is not defined. Please define the function before calling add.interval.col.",
Expand Down Expand Up @@ -99,7 +99,7 @@ test_that("add.interval.col", {
regexp="All names for the formalsmap list must be arguments to the function",
info="formalsmap arguments must map to function arguments"
)

expect_equal(
{
add.interval.col(name="a", FUN=NA, unit_type="conc", pretty_name="a", datatype="interval", desc="test addition")
Expand Down Expand Up @@ -170,7 +170,7 @@ test_that("fake parameters", {
depends="does_not_exist"
)
expect_error(
sort.interval.cols(),
sort_interval_cols(),
regexp="Invalid dependencies for interval column (please report this as a bug): fake_parameter The following dependencies are missing: does_not_exist",
fixed=TRUE
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test_that("AIC.list", {
test_that("AIC_list", {
tmpdat <- data.frame(x=c(1, 2, 3), y=c(1, 2.02, 3), z=c(0, 0.01, 0))
mod1 <- glm(y~x, data=tmpdat)
mod2 <- glm(y~x+z, data=tmpdat)
Expand All @@ -8,7 +8,7 @@ test_that("AIC.list", {
indentation=c(1, 0),
isBest=c("", "Best Model"),
stringsAsFactors=FALSE)
expect_equal(AIC.list(d1), result1)
expect_equal(AIC_list(d1), result1)

# Check that simple names apply correctly
d2 <- list(list("A"=mod1), "B"=mod2)
Expand All @@ -18,7 +18,7 @@ test_that("AIC.list", {
isBest=c("", "Best Model"),
stringsAsFactors=FALSE,
row.names=c("A", "B"))
expect_equal(AIC.list(d2), result2)
expect_equal(AIC_list(d2), result2)

d3 <- list("A"=mod1, "B"=mod2)
result3 <- data.frame(AIC=c(as.numeric(AIC(mod1)), as.numeric(AIC(mod2))),
Expand All @@ -27,16 +27,16 @@ test_that("AIC.list", {
isBest=c("", "Best Model"),
stringsAsFactors=FALSE,
row.names=c("A", "B"))
expect_equal(AIC.list(d3), result3)
expect_equal(AIC_list(d3), result3)

d4 <- list("C"=list("A"=mod1), "B"=mod2)
result4 <- data.frame(AIC=c(as.numeric(AIC(mod1)), as.numeric(AIC(mod2))),
df=c(3, 4),
indentation=c(1, 0),
isBest=c("", "Best Model"),
stringsAsFactors=FALSE,
row.names=c("C A", "B"))
expect_equal(AIC.list(d4), result4)
expect_equal(AIC_list(d4), result4)

d5 <- list("C"=list("A"=mod1), "B"=mod2, C=NA)
result5 <- data.frame(AIC=c(as.numeric(AIC(mod1)), as.numeric(AIC(mod2)), NA),
Expand All @@ -45,8 +45,7 @@ test_that("AIC.list", {
isBest=c("", "Best Model", ""),
stringsAsFactors=FALSE,
row.names=c("C A", "B", "C"))
expect_equal(AIC.list(d5), result5)

expect_equal(AIC_list(d5), result5)
})

test_that("get.best.model", {
Expand Down
Loading