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
12 changes: 12 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ export(pk.calc.aumc.inf)
export(pk.calc.aumc.inf.obs)
export(pk.calc.aumc.inf.pred)
export(pk.calc.aumc.last)
export(pk.calc.aumcint)
export(pk.calc.aumcint.all)
export(pk.calc.aumcint.inf.obs)
export(pk.calc.aumcint.inf.pred)
export(pk.calc.aumcint.last)
export(pk.calc.aumciv)
export(pk.calc.auxc)
export(pk.calc.c0)
export(pk.calc.cav)
Expand All @@ -204,6 +210,9 @@ export(pk.calc.cstart)
export(pk.calc.ctrough)
export(pk.calc.deg.fluc)
export(pk.calc.dn)
export(pk.calc.ermax)
export(pk.calc.ertlst)
export(pk.calc.ertmax)
export(pk.calc.f)
export(pk.calc.fe)
export(pk.calc.half.life)
Expand All @@ -214,6 +223,8 @@ export(pk.calc.mrt.md)
export(pk.calc.ptr)
export(pk.calc.sparse_auc)
export(pk.calc.sparse_auclast)
export(pk.calc.sparse_aumc)
export(pk.calc.sparse_aumclast)
export(pk.calc.swing)
export(pk.calc.tfirst)
export(pk.calc.thalf.eff)
Expand Down Expand Up @@ -244,6 +255,7 @@ export(superposition)
export(time_calc)
export(ungroup)
export(var_sparse_auc)
export(var_sparse_aumc)
importFrom(dplyr,"%>%")
importFrom(dplyr,filter)
importFrom(dplyr,full_join)
Expand Down
23 changes: 22 additions & 1 deletion R/PKNCA.options.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,28 @@
}
x
},
first.ertmax=function(x, default=FALSE, description=FALSE) {
if (description)
return(paste(
"If there is more than one concentration equal to maximum excretion rate, which time",
"should be selected for ertmax? If 'TRUE', the first will be selected.",
"If 'FALSE', the last will be selected."))
if (default)
return(TRUE)
if (length(x) != 1)
stop("first.ertmax must be a scalar")
if (is.na(x))
stop("first.ertmax may not be NA")
if (!is.logical(x)) {
x <- as.logical(x)
if (is.na(x)) {
stop("Could not convert first.ertmax to a logical value")
} else {
warning("Converting first.ertmax to a logical value: ", x)
}
}
x
},
first.tmax=function(x, default=FALSE, description=FALSE) {
if (description)
return(paste(
Expand Down Expand Up @@ -579,4 +601,3 @@ PKNCA.set.summary <- function(name, description, point, spread,
assign("summary", current, envir=.PKNCAEnv)
invisible(current)
}

20 changes: 10 additions & 10 deletions R/pk.calc.urine.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ PKNCA.set.summary(
#' @param time The starting time of the collection interval
#' @param duration.conc The duration of the collection interval
#' @param check Should the concentration and time data be checked?
#' @param first.tmax If TRUE, return the first time of maximum excretion rate; otherwise, return the last
#' @param first.ertmax If TRUE, return the first time of maximum excretion rate; otherwise, return the last
#' @return The midpoint collection time of the maximum excretion rate, or NA if not available
#' @export
pk.calc.ertmax <- function(conc, volume, time, duration.conc, check = TRUE, first.tmax = NULL) {

pk.calc.ertmax <- function(conc, volume, time, duration.conc, check = TRUE, first.ertmax = NULL) {
first.ertmax <- PKNCA.choose.option(name="first.ertmax", value=first.ertmax, options=options)
# Generate messages about missing concentrations/volumes
message_all <- generate_missing_messages(conc, volume,
name_a = "concentrations",
Expand All @@ -258,7 +258,7 @@ pk.calc.ertmax <- function(conc, volume, time, duration.conc, check = TRUE, firs
midtime <- time + duration.conc / 2
ret <- midtime[er %in% ermax]

if (first.tmax) {
if (first.ertmax) {
ret <- ret[1]
} else {
ret <- ret[length(ret)]
Expand Down Expand Up @@ -299,32 +299,32 @@ generate_missing_messages <- function(a, b,

mask_a <- is.na(a)
mask_b <- is.na(b)

mask_both <- mask_a & mask_b
mask_a_only <- mask_a & !mask_both
mask_b_only <- mask_b & !mask_both

msg_both <- msg_a <- msg_b <- NA_character_
n <- length(mask_a)

if (all(mask_both)) {
msg_both <- sprintf("All %s and %s are missing", name_a, name_b)
} else if (any(mask_both)) {
msg_both <- sprintf("%g of %g %s and %s are missing", sum(mask_both), n, name_a, name_b)
}

if (all(mask_a_only)) {
msg_a <- sprintf("All %s are missing", name_a)
} else if (any(mask_a_only)) {
msg_a <- sprintf("%g of %g %s are missing", sum(mask_a_only), n, name_a)
}

if (all(mask_b_only)) {
msg_b <- sprintf("All %s are missing", name_b)
} else if (any(mask_b_only)) {
msg_b <- sprintf("%g of %g %s are missing", sum(mask_b_only), n, name_b)
}

# Return non-NA messages
stats::na.omit(c(msg_both, msg_a, msg_b))
}
1 change: 1 addition & 0 deletions man/as_sparse_pk.Rd

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

51 changes: 51 additions & 0 deletions man/aumc_integrate.Rd

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

153 changes: 153 additions & 0 deletions man/pk.calc.aumcint.Rd

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

36 changes: 36 additions & 0 deletions man/pk.calc.aumciv.Rd

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

Loading
Loading