get_impute_method() is the rule pk.nca() uses to find the imputation
methods for each interval, from the impute argument of PKNCAdata() and
the intervals. It reads impute one of three ways, in this order:
Value
A character vector of imputation specifications: one per row of
intervals when read from a column, and of length one otherwise (the
method string, or NA_character_ for no imputation). A column that is
not character is an error, except that a column of only NA (which is
logical when made with NA) is read as no imputation.
Details
If
imputeis the name of a column inintervals, the methods are that column's values, one per interval. The name may be any column name, not only"impute".Otherwise, if
imputeisNAandintervalshas a column named"impute", the methods are that column's values, one per interval.Otherwise
imputeis itself the method (or comma- or space-separated methods) for every interval, and the result isimputeas a single value. AnNAthat finds no"impute"column therefore gives a singleNA_character_, meaning no imputation.
get_impute_method() only reads the specification. It does not check that
the methods exist; assert_impute_method() does. get_impute_column()
gives the name of the column the methods are read from, which tells a column
from a method string even for an intervals table with one row.
Examples
intervals <- data.frame(start = 0, end = 24, impute = "start_conc0")
# The column named by `impute`
get_impute_method(intervals, impute = "impute")
#> [1] "start_conc0"
# NA finds the column named "impute"
get_impute_method(intervals, impute = NA)
#> [1] "start_conc0"
# NA without an "impute" column means no imputation
get_impute_method(intervals[, c("start", "end")], impute = NA)
#> [1] NA
# Anything else is the method for every interval
get_impute_method(intervals, impute = "start_predose")
#> [1] "start_predose"