| Title: | Non-Compartmental Analysis for Campsis Simulation Platform |
|---|---|
| Description: | A flexible and user-friendly non-compartmental analysis (NCA) toolkit designed to work seamlessly with simulated pharmacokinetic data generated using the 'campsis' ecosystem. The package provides a comprehensive framework to compute standard and custom NCA metrics, including exposure (AUC), peak/trough concentrations, half-life and time-above/below thresholds, with support for configurable time windows and summary statistics. 'campsisnca' integrates tightly with 'campsis' and 'campsismod', enabling streamlined workflows from simulation to analysis. In addition, the package provides a JSON-based interface to define NCA analyses, metrics and options using formal schemas, allowing analyses to be created, validated and executed outside of R and facilitating reproducibility, automation and system integration. The package also includes utilities for generating formatted summary tables and exporting results in multiple formats suitable for reporting. Trapezoidal rule implementation for AUC calculation is based on the 'qpNCA' package by Huisman, Jolling, Mehta and Bergsma (2021) <doi:10.32614/CRAN.package.qpNCA>, following methodology from Rowland and Tozer (2011, ISBN:978-0-683-07404-8). The package itself is licensed under the GPL (>= 3); the JSON schema files shipped in inst/extdata are licensed separately under the Creative Commons Attribution 4.0 International (CC BY 4.0). |
| Authors: | Nicolas Luyckx [aut, cre], Calvagone [cph] |
| Maintainer: | Nicolas Luyckx <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.7.2 |
| Built: | 2026-09-30 20:28:19 UTC |
| Source: | https://github.com/calvagone/campsisnca |
Apply time window.
apply_time_window(x, window, data_time_unit, ...) ## S4 method for signature 'ANY,nca_time_window,character' apply_time_window(x, window, data_time_unit)apply_time_window(x, window, data_time_unit, ...) ## S4 method for signature 'ANY,nca_time_window,character' apply_time_window(x, window, data_time_unit)
x |
input data for the calculation, data frame |
window |
time window |
data_time_unit |
time unit of TIME column in data (x argument) |
... |
extra arguments |
updated object
'r lifecycle::badge("deprecated")'
applyTimeWindow(x, window, data_time_unit, ...)applyTimeWindow(x, window, data_time_unit, ...)
x |
input data for the calculation, data frame |
window |
time window |
data_time_unit |
time unit of TIME column in data (x argument) |
... |
extra arguments |
'applyTimeWindow()' is deprecated in favor of 'apply_time_window()'.
updated object
AUC.
AUC( variable = NULL, window = NULL, method = 1, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )AUC( variable = NULL, window = NULL, method = 1, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
method |
method: * 1: linear up - linear down * 2: linear up - logarithmic down * 3: linear before Tmax, logarithmic after Tmax |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
Trapezoidal rule implementation for AUC calculation is based on the 'qpNCA' package by Huisman, Jolling, Mehta and Bergsma (2021) <doi:10.32614/CRAN.package.qpNCA>, following methodology from Rowland and Tozer (2011, ISBN:978-0-683-07404-8).
an object of class auc_metric
Avg.
Avg( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Avg( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class avg_metric
Calculate.
calculate(object, x, options = NULL, ...) ## S4 method for signature 'nca_metric,ANY' calculate(object, x, options = NULL, ...) ## S4 method for signature 'theoretical_thalf_metric,ANY' calculate(object, x, options = NULL, ...) ## S4 method for signature 'nca_analysis,ANY' calculate(object, x, options = NULL, ...) ## S4 method for signature 'nca_analyses,ANY' calculate(object, x, options = NULL, ...) ## S4 method for signature 'nca_table,ANY' calculate(object, x, options = NULL, ...) ## S4 method for signature 'replicated_nca_table,campsis_output' calculate(object, x, options = NULL, ...)calculate(object, x, options = NULL, ...) ## S4 method for signature 'nca_metric,ANY' calculate(object, x, options = NULL, ...) ## S4 method for signature 'theoretical_thalf_metric,ANY' calculate(object, x, options = NULL, ...) ## S4 method for signature 'nca_analysis,ANY' calculate(object, x, options = NULL, ...) ## S4 method for signature 'nca_analyses,ANY' calculate(object, x, options = NULL, ...) ## S4 method for signature 'nca_table,ANY' calculate(object, x, options = NULL, ...) ## S4 method for signature 'replicated_nca_table,campsis_output' calculate(object, x, options = NULL, ...)
object |
object (NCA table, NCA analyses, NCA analysis, PK metric) where calculation is applied |
x |
input data for the calculation, data frame |
options |
NCA options |
... |
extra arguments |
updated object
A class union containing standard data frames, tibbles, and Campsis-specific table objects.
A class union containing standard data frames, tibbles, and Campsisnca-specific table objects.
Campsisnca table class (see this class as an interface)
CAt (concentration at specific time).
CAt( variable = NULL, window = NULL, time = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )CAt( variable = NULL, window = NULL, time = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
time |
what time to read the concentrations. If not provided, last concentrations from x will be returned. |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class conc_at_metric
Cavg.
Cavg( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Cavg( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class cavg_metric
Alias for Change from Baseline (CFB).
CFB( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL, method = "difference" )CFB( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL, method = "difference" )
variable |
dependent variable |
window |
time window on which this metric should be computed |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
method |
Character string specifying the calculation method. Must be one of "difference" (default), "percent", "ratio", or "log". |
an object of class cfb_metric
Change from Baseline metric class.
methodCharacter string specifying the CFB method ("difference", "percent", "ratio", "log").
Change from Baseline (CFB).
ChangeFromBaseline( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL, method = "difference" )ChangeFromBaseline( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL, method = "difference" )
variable |
dependent variable |
window |
time window on which this metric should be computed |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
method |
Character string specifying the calculation method. Must be one of "difference" (default), "percent", "ratio", or "log". |
an object of class cfb_metric
Cmax.
Cmax( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Cmax( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class cmax_metric
Cmin
Cmin( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Cmin( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class cmin_metric
Compute NCA metric summary.
compute_nca_metric_summary(object, strat_vars, quantile_type)compute_nca_metric_summary(object, strat_vars, quantile_type)
object |
NCA metric |
strat_vars |
stratification variable names in data |
quantile_type |
type of quantile |
data frame
Compute the duration of a line segment above or below a certain limit.
computeTimeAboveBelow(x1, y1, x2, y2, above, strictly)computeTimeAboveBelow(x1, y1, x2, y2, above, strictly)
x1 |
x-coordinate of the first point |
y1 |
y-coordinate of the first point |
x2 |
x-coordinate of the second point |
y2 |
y-coordinate of the second point |
above |
whether the line segment is above the limit |
strictly |
whether the line segment is strictly above or below the limit |
the duration of the line segment above or below the limit
Ctrough. Last time in x shall be considered as the trough time. Similar to Last, but for concentrations.
Ctrough( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Ctrough( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class ctrough_metric
Custom metric (input data as time and value vectors).
CustomMetric( variable = NULL, window = NULL, fun, name = NULL, unit = NULL, categorical = FALSE, stat_display = get_stat_display_default(categorical), digits = NULL )CustomMetric( variable = NULL, window = NULL, fun, name = NULL, unit = NULL, categorical = FALSE, stat_display = get_stat_display_default(categorical), digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
fun |
any custom function with exactly 2 arguments: time and value |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
categorical |
categorical endpoint, logical |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class custom_metric
Custom metric (input data as tibble).
CustomMetricTbl( window = NULL, fun, name = NULL, unit = NULL, categorical = FALSE, stat_display = get_stat_display_default(categorical), digits = NULL )CustomMetricTbl( window = NULL, fun, name = NULL, unit = NULL, categorical = FALSE, stat_display = get_stat_display_default(categorical), digits = NULL )
window |
time window on which this metric should be computed |
fun |
any custom function with exactly 1 argument: data |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
categorical |
categorical endpoint, logical |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class custom_metric
Compute the coefficient of variation.
cv(x)cv(x)
x |
numeric vector |
numeric value
Custom deparse function. Works similarly to deparse1. However, lines are trimmed before being concatenated.
deparse_digits(digits)deparse_digits(digits)
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these) |
a character vector, which will be pasted and given to gtsummary
Deparse 1 line.
deparse_one_line(x)deparse_one_line(x)
x |
expression to deparse |
a single string
Discard category column.
discard_category_column(x, split = "_")discard_category_column(x, split = "_")
x |
summary export |
split |
string use to concatenate the 'stat' and 'category' column |
updated data frame
'r lifecycle::badge("deprecated")'
discardCategoryColumn(x, split = "_")discardCategoryColumn(x, split = "_")
x |
summary export |
split |
string use to concatenate the 'stat' and 'category' column |
'discardCategoryColumn()' is deprecated in favor of 'discard_category_column()'.
updated object
Export replicated NCA table.
## S4 method for signature 'replicated_nca_table,character' export(object, dest, ...)## S4 method for signature 'replicated_nca_table,character' export(object, dest, ...)
object |
replicated_nca_table object |
dest |
destination for the summarised table, either "dataframe", "gtsummary" or "gt" |
... |
extra arguments |
a data frame, a gtsummary object or a gt object, depending on the destination
Extract values from within braces.
extract_brace_values(x)extract_brace_values(x)
x |
input string |
a character vector
Generate table code.
generate_table_code(object, init = NULL, ...) ## S4 method for signature 'nca_table,logical' generate_table_code(object, init = NULL, ...)generate_table_code(object, init = NULL, ...) ## S4 method for signature 'nca_table,logical' generate_table_code(object, init = NULL, ...)
object |
table object |
init |
generate initialization code to generate the individuals, default is TRUE |
... |
extra arguments |
a character vector containing the code
Compute the geometric CV.
geocv(x)geocv(x)
x |
numeric vector |
numeric value
Compute the geometric mean.
geomean(x)geomean(x)
x |
numeric vector |
numeric value
Filters a vector of column names to include only those present in a data frame that are of class character (and optionally factor).
get_character_cols_only(x, cols, include_factor = FALSE)get_character_cols_only(x, cols, include_factor = FALSE)
x |
A data frame or tibble. |
cols |
A character vector of candidate column names. |
include_factor |
Logical. If |
A character vector of column names matching the specified class criteria.
Get default name.
get_default_name(object, ...) ## S4 method for signature 'nca_metric' get_default_name(object, ...) ## S4 method for signature 'auc_metric' get_default_name(object, ...) ## S4 method for signature 'max_metric' get_default_name(object, ...) ## S4 method for signature 'cmax_metric' get_default_name(object, ...) ## S4 method for signature 'tmax_metric' get_default_name(object, ...) ## S4 method for signature 'min_metric' get_default_name(object, ...) ## S4 method for signature 'cmin_metric' get_default_name(object, ...) ## S4 method for signature 'tmin_metric' get_default_name(object, ...) ## S4 method for signature 'value_at_metric' get_default_name(object, ...) ## S4 method for signature 'conc_at_metric' get_default_name(object, ...) ## S4 method for signature 'last_metric' get_default_name(object, ...) ## S4 method for signature 'ctrough_metric' get_default_name(object, ...) ## S4 method for signature 'avg_metric' get_default_name(object, ...) ## S4 method for signature 'cavg_metric' get_default_name(object, ...) ## S4 method for signature 'thalf_metric' get_default_name(object, ...) ## S4 method for signature 'theoretical_thalf_metric' get_default_name(object, ...) ## S4 method for signature 'time_above_limit_metric' get_default_name(object, ...) ## S4 method for signature 'time_below_limit_metric' get_default_name(object, ...) ## S4 method for signature 'cfb_metric' get_default_name(object, ...)get_default_name(object, ...) ## S4 method for signature 'nca_metric' get_default_name(object, ...) ## S4 method for signature 'auc_metric' get_default_name(object, ...) ## S4 method for signature 'max_metric' get_default_name(object, ...) ## S4 method for signature 'cmax_metric' get_default_name(object, ...) ## S4 method for signature 'tmax_metric' get_default_name(object, ...) ## S4 method for signature 'min_metric' get_default_name(object, ...) ## S4 method for signature 'cmin_metric' get_default_name(object, ...) ## S4 method for signature 'tmin_metric' get_default_name(object, ...) ## S4 method for signature 'value_at_metric' get_default_name(object, ...) ## S4 method for signature 'conc_at_metric' get_default_name(object, ...) ## S4 method for signature 'last_metric' get_default_name(object, ...) ## S4 method for signature 'ctrough_metric' get_default_name(object, ...) ## S4 method for signature 'avg_metric' get_default_name(object, ...) ## S4 method for signature 'cavg_metric' get_default_name(object, ...) ## S4 method for signature 'thalf_metric' get_default_name(object, ...) ## S4 method for signature 'theoretical_thalf_metric' get_default_name(object, ...) ## S4 method for signature 'time_above_limit_metric' get_default_name(object, ...) ## S4 method for signature 'time_below_limit_metric' get_default_name(object, ...) ## S4 method for signature 'cfb_metric' get_default_name(object, ...)
object |
get default name of this object |
... |
optional extra arguments |
a character string (the default name)
Get digits code for gtsummary.
get_digits_code(table)get_digits_code(table)
table |
NCA table |
code
Get labels code for gtsummary.
get_labels_code(table, subscripts)get_labels_code(table, subscripts)
table |
NCA table |
subscripts |
use subscripts, logical value |
code
Get the name of the metric in LaTeX notation (with subscript coded with an underscore and brackets).
get_latex_name(x, ...) ## S4 method for signature 'nca_metric' get_latex_name(x) ## S4 method for signature 'abstract_max_metric' get_latex_name(x) ## S4 method for signature 'tmax_metric' get_latex_name(x) ## S4 method for signature 'abstract_min_metric' get_latex_name(x) ## S4 method for signature 'tmin_metric' get_latex_name(x) ## S4 method for signature 'abstract_value_at_metric' get_latex_name(x) ## S4 method for signature 'last_metric' get_latex_name(x) ## S4 method for signature 'ctrough_metric' get_latex_name(x) ## S4 method for signature 'abstract_avg_metric' get_latex_name(x) ## S4 method for signature 'thalf_metric' get_latex_name(x) ## S4 method for signature 'theoretical_thalf_metric' get_latex_name(x) ## S4 method for signature 'cfb_metric' get_latex_name(x)get_latex_name(x, ...) ## S4 method for signature 'nca_metric' get_latex_name(x) ## S4 method for signature 'abstract_max_metric' get_latex_name(x) ## S4 method for signature 'tmax_metric' get_latex_name(x) ## S4 method for signature 'abstract_min_metric' get_latex_name(x) ## S4 method for signature 'tmin_metric' get_latex_name(x) ## S4 method for signature 'abstract_value_at_metric' get_latex_name(x) ## S4 method for signature 'last_metric' get_latex_name(x) ## S4 method for signature 'ctrough_metric' get_latex_name(x) ## S4 method for signature 'abstract_avg_metric' get_latex_name(x) ## S4 method for signature 'thalf_metric' get_latex_name(x) ## S4 method for signature 'theoretical_thalf_metric' get_latex_name(x) ## S4 method for signature 'cfb_metric' get_latex_name(x)
x |
metric |
... |
extra arguments, not used |
a character string
Get statistics code for gtsummary.
get_statistics_code(table)get_statistics_code(table)
table |
NCA table |
code
Get all stratas.
get_strata(object, keep_single = NULL, ...) ## S4 method for signature 'nca_table,logical' get_strata(object, keep_single = NULL, ...)get_strata(object, keep_single = NULL, ...) ## S4 method for signature 'nca_table,logical' get_strata(object, keep_single = NULL, ...)
object |
table object |
keep_single |
keep single stratification values, logical (default TRUE) |
... |
extra arguments |
list of stratification variable names
Get table summary code.
get_table_summary_code( variable, data, by, stats, type, labels, digits, combine_with, header_label )get_table_summary_code( variable, data, by, stats, type, labels, digits, combine_with, header_label )
variable |
assigned variable name |
data |
data frame code |
by |
variable |
stats |
stats to compute |
type |
type of the variables |
labels |
the labels to display |
digits |
the digits to be used for rounding |
combine_with |
either 'tbl_stack' or 'tbl_merge' |
header_label |
header label name |
data frame
Get the unit corresponding to the given metric.
get_unit(object, metric, ...) ## S4 method for signature 'nca_metrics,character' get_unit(object, metric, ...) ## S4 method for signature 'nca_analysis,character' get_unit(object, metric, ...) ## S4 method for signature 'nca_table,character' get_unit(object, metric, ...)get_unit(object, metric, ...) ## S4 method for signature 'nca_metrics,character' get_unit(object, metric, ...) ## S4 method for signature 'nca_analysis,character' get_unit(object, metric, ...) ## S4 method for signature 'nca_table,character' get_unit(object, metric, ...)
object |
any object that contains units |
metric |
given metric name |
... |
extra arguments, not used |
a character string (the unit)
Get the variable type code for gtsummary.
get_variable_type_code(table, all_dichotomous_levels)get_variable_type_code(table, all_dichotomous_levels)
table |
NCA table |
all_dichotomous_levels |
show all dichotomous levels (0 and 1) when data is dichotomous |
code
Get Campsisnca option logic.
getCampsisncaOption(name, default)getCampsisncaOption(name, default)
name |
option to search |
default |
default value if option not found |
option value
Glue stat display string.
glue_stat_display(stat_display, stats, summary, digits)glue_stat_display(stat_display, stats, summary, digits)
stat_display |
stat display string |
stats |
statistics, character vector |
summary |
summary data frame |
digits |
digits to be used for rounding |
glued string
Compute the individual value of an individual.
i_value(object, time, value = NULL) ## S4 method for signature 'auc_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'abstract_max_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'tmax_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'abstract_min_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'tmin_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'abstract_value_at_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'abstract_last_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'abstract_avg_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'thalf_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature ## 'abstract_time_above_or_below_limit_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'cfb_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'custom_metric,numeric,numeric' i_value(object, time, value = NULL)i_value(object, time, value = NULL) ## S4 method for signature 'auc_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'abstract_max_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'tmax_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'abstract_min_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'tmin_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'abstract_value_at_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'abstract_last_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'abstract_avg_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'thalf_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature ## 'abstract_time_above_or_below_limit_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'cfb_metric,numeric,numeric' i_value(object, time, value = NULL) ## S4 method for signature 'custom_metric,numeric,numeric' i_value(object, time, value = NULL)
object |
PK metric |
time |
time vector, numeric |
value |
value vector, numeric |
individual value
Compute the individual value of an individual.
i_value_tbl(object, data, ...) ## S4 method for signature 'custom_metric,tbl_df' i_value_tbl(object, data)i_value_tbl(object, data, ...) ## S4 method for signature 'custom_metric,tbl_df' i_value_tbl(object, data)
object |
PK metric |
data |
individual data, tibble |
... |
extra arguments |
individual value
Compute the individual values on a simulation output.
i_values(object, x, options, strat_vars, ...) ## S4 method for signature 'nca_metric' i_values(object, x, options, strat_vars, ...)i_values(object, x, options, strat_vars, ...) ## S4 method for signature 'nca_metric' i_values(object, x, options, strat_vars, ...)
object |
PK metric |
x |
input data for the calculation, data frame |
options |
NCA options |
strat_vars |
stratification variable names |
... |
extra arguments |
individual values
Individual (wide format) Campsisnca table class
'r lifecycle::badge("deprecated")'
iValue(object, time, value = NULL)iValue(object, time, value = NULL)
object |
PK metric |
time |
time vector, numeric |
value |
value vector, numeric |
'iValue()' is deprecated in favor of 'i_value()'.
individual value
Last value.
Last( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Last( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class last_metric
Max.
Max( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Max( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class max_metric
Theoretical metrics for 1-cpt model results.
metrics.1cpt(x, map = character(0))metrics.1cpt(x, map = character(0))
x |
CAMPSIS/NONMEM dataframe |
map |
character vector used for column mapping, only one key is possible: K |
theoretical metrics
Theoretical metrics for 2-cpt model results.
metrics.2cpt(x, map = character(0))metrics.2cpt(x, map = character(0))
x |
CAMPSIS/NONMEM dataframe |
map |
character vector used for column mapping, keys to be chosen among: DOSE, TAU, CL, V2, Q, V3, KA |
theoretical metrics
Pre-processing for metrics.1cpt and metrics.2cpt.
metrics.common(x, map, thalf.1cpt)metrics.common(x, map, thalf.1cpt)
x |
CAMPSIS/NONMEM dataframe |
map |
character vector used for column mapping, only one key is possible: K |
thalf.1cpt |
logical value |
theoretical metrics
Min.
Min( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Min( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class min_metric
NCA metric class. See this class as abstract class.
NCA metrics class. See this class as a list of NCA metrics.
Create an NCA analysis.
NCAAnalysis( name = "Default", window = TimeWindow(), variable = NULL, strata = get_default_strata() )NCAAnalysis( name = "Default", window = TimeWindow(), variable = NULL, strata = get_default_strata() )
name |
name of this analysis, e.g. 'Day 1' |
window |
time window, see TimeWindow |
variable |
default variable which is analysed |
strata |
strata levels this analysis refers to, named vector, e.g. c(ARM='1g QD'). Note, the default strata are c(SCENARIO='all', ARM='all'). Use 'all' if this analysis refers to all levels for the specified stratification variable. By default, a stratification variable that has only 1 level is ignored. |
an object of class nca_analysis
NCA metrics
NCAMetrics()NCAMetrics()
an object of class nca_metrics
NCA table (deprecated).
NCAMetricsTable( title = NULL, subtitle = NULL, swap_strat = FALSE, combine_with = "tbl_stack", show_all_levels = FALSE, header_label = "Metric", subscripts = TRUE, nca_options = NCAOptions(), tab_options = list(), json = NULL )NCAMetricsTable( title = NULL, subtitle = NULL, swap_strat = FALSE, combine_with = "tbl_stack", show_all_levels = FALSE, header_label = "Metric", subscripts = TRUE, nca_options = NCAOptions(), tab_options = list(), json = NULL )
title |
table title, optional character value |
subtitle |
table subtitle, optional character value |
swap_strat |
swap stratification variables in table (only useful when 2 stratification variables are given) |
combine_with |
either 'tbl_stack' or 'tbl_merge' |
show_all_levels |
show all dichotomous levels in table |
header_label |
'Metric' by default |
subscripts |
use LaTeX subcripts/superscripts notation when writing labels |
nca_options |
NCA options, see ?NCAOptions |
tab_options |
list of options to pass to gt::tab_options |
json |
path to JSON table file or JSON content in string form |
an object of class nca_table
NCA options used for calculation of metrics.
NCAOptions( quantile_type = 2L, data_time_unit = "hour", table_time_unit = "hour" )NCAOptions( quantile_type = 2L, data_time_unit = "hour", table_time_unit = "hour" )
quantile_type |
type of quantile to use (see ?quantile), default value in campsisnca is 2 (aligned with gtsummary) |
data_time_unit |
time unit of the data given to 'calculate' |
table_time_unit |
time unit in table (for time-dependent metrics like AUC, Time above and below, etc.) |
an object of class nca_options
NCA table.
NCATable( title = NULL, subtitle = NULL, swap_strat = FALSE, combine_with = "tbl_stack", show_all_levels = FALSE, header_label = "Metric", subscripts = TRUE, nca_options = NCAOptions(), tab_options = list(), json = NULL )NCATable( title = NULL, subtitle = NULL, swap_strat = FALSE, combine_with = "tbl_stack", show_all_levels = FALSE, header_label = "Metric", subscripts = TRUE, nca_options = NCAOptions(), tab_options = list(), json = NULL )
title |
table title, optional character value |
subtitle |
table subtitle, optional character value |
swap_strat |
swap stratification variables in table (only useful when 2 stratification variables are given) |
combine_with |
either 'tbl_stack' or 'tbl_merge' |
show_all_levels |
show all dichotomous levels in table |
header_label |
'Metric' by default |
subscripts |
use LaTeX subcripts/superscripts notation when writing labels |
nca_options |
NCA options, see ?NCAOptions |
tab_options |
list of options to pass to gt::tab_options |
json |
path to JSON table file or JSON content in string form |
an object of class nca_table
A simulated 2-compartment oral dataset containing 200 subjects administered 1000 mg bolus doses every 24 hours for 7 days. Includes rich sampling on Day 1 and Day 7, sparse sampling on intermediate days, and weight-based allometric scaling on clearance.
pk_bolus_mdpk_bolus_md
A tibble with 5,000 rows and 16 variables:
Subject identifier (1–200)
Time after initial dose (hours)
Study arm identifier
Amount in the depot (absorption) compartment (mg)
Amount in the central compartment (mg)
Amount in the peripheral compartment (mg)
Eliminated amount (mg)
Body weight covariate (kg), sampled from Uniform(50, 100)
Individual clearance (L/h), allometrically scaled with body weight
Central volume of distribution (L)
Inter-compartmental clearance (L/h)
Peripheral volume of distribution (L)
Absorption rate constant (1/h)
True plasma concentration in central compartment (mg/L or mcg/mL)
Observed plasma concentration with ~15.8% proportional residual variability
Observation variable (identical to OBS_CP)
Simulated using the campsis package (ADVAN4/TRANS4 model).
data(pk_bolus_md) head(pk_bolus_md)data(pk_bolus_md) head(pk_bolus_md)
Converts target columns into factors using their current unique row appearance order as the factor levels.
preserve_column_levels(x, cols)preserve_column_levels(x, cols)
x |
a data frame or tibble. |
cols |
a character vector of column names to convert. |
a data frame with updated factor columns.
Converts target columns from factors into standard character vectors.
remove_column_levels(x, cols)remove_column_levels(x, cols)
x |
a data frame or tibble. |
cols |
a character vector of column names to convert. |
a data frame with character columns.
Replicated NCA table.
ReplicatedNCATable( title = NULL, subtitle = NULL, selected_statistics = character(), summary_stat_display = get_stat_display_default(), summary_stat_signif_digits = 3L, strata = get_default_strata(), tab_options = list(), json = NULL )ReplicatedNCATable( title = NULL, subtitle = NULL, selected_statistics = character(), summary_stat_display = get_stat_display_default(), summary_stat_signif_digits = 3L, strata = get_default_strata(), tab_options = list(), json = NULL )
title |
table title, optional character value |
subtitle |
table subtitle, optional character value |
selected_statistics |
NCA metrics statistics to keep (e.g. mean, etc) when summary statistics are computed on replicated output. Default is the empty character vector (all statistics are computed). |
summary_stat_display |
display format for replicate statistics, character vector. Default is |
summary_stat_signif_digits |
number of significant digits to display for replicate statistics, default is 3. |
strata |
strata levels this analysis refers to, named vector, e.g. c(ARM='1g QD'). Note, the default strata are c(SCENARIO='all', ARM='all'). Use 'all' if this analysis refers to all levels for the specified stratification variable. By default, a stratification variable that has only 1 level is ignored. |
tab_options |
list of options to pass to gt::tab_options |
json |
path to JSON table file or JSON content in string form |
an object of class replicated_nca_table
Re-applies saved factor levels back onto target columns, optionally physically sorts the rows by the restored factor order, and optionally converts the columns back to character vectors.
restore_column_levels(x, saved_levels, arrange = TRUE, to_character = FALSE)restore_column_levels(x, saved_levels, arrange = TRUE, to_character = FALSE)
x |
a data frame or tibble. |
saved_levels |
a named list of character vectors representing factor levels
(typically created by |
arrange |
logical. If |
to_character |
logical. If |
a data frame with restored factor (or character) columns and optionally reordered rows.
Extracts factor levels (or unique value order for non-factors) for target columns and stores them in a named list for later restoration.
save_column_levels(x, cols)save_column_levels(x, cols)
x |
a data frame or tibble. |
cols |
a character vector of column names whose levels should be saved. |
a named list where names correspond to column names and values contain character vectors of factor levels.
Compute the standard error.
se(x)se(x)
x |
numeric vector |
numeric value
Return the evaluated statistics display string. This method was kept for backward compatibility in the tests. It is recommended to call 'export(dest="dataframe", type="summary_pretty")' on the NCA table instead.
stat_display_string(object, ...) ## S4 method for signature 'nca_metric' stat_display_string(object, ...)stat_display_string(object, ...) ## S4 method for signature 'nca_metric' stat_display_string(object, ...)
object |
PK metric |
... |
extra arguments |
a string, e.g. 100 [45-143]
Summary (pretty format) Campsisnca table class
Summary (wide format) Campsisnca table class
Terminal half life computed by making a linear regression in the log domain on the given data x.
Thalf( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Thalf( variable = NULL, window = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class thalf_metric
Theoretical half life for a 1-compartment model.
Thalf.1cpt( map = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Thalf.1cpt( map = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
map |
character vector used for column mapping, only one key is possible: K |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class theoretical_thalf_metric
Thalf metric required columns for a 1-compartment model.
thalf.1cpt.required()thalf.1cpt.required()
character vector of required column names
Theoretical distribution half life for a 2-compartment model.
Thalf.2cpt.dist( map = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Thalf.2cpt.dist( map = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
map |
character vector used for column mapping, keys to be chosen among: DOSE, TAU, CL, V2, Q, V3, KA |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class theoretical_thalf_metric
Theoretical effective half life for a 2-compartment model.
Thalf.2cpt.eff( map = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Thalf.2cpt.eff( map = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
map |
character vector used for column mapping, keys to be chosen among: DOSE, TAU, CL, V2, Q, V3, KA |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class theoretical_thalf_metric
Thalf metric required columns for a 2-compartment model.
thalf.2cpt.required()thalf.2cpt.required()
character vector of required column names
Theoretical elimination half life for a 2-compartment model.
Thalf.2cpt.z( map = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Thalf.2cpt.z( map = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
map |
character vector used for column mapping, keys to be chosen among: DOSE, TAU, CL, V2, Q, V3, KA |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class theoretical_thalf_metric
Time above a certain limit.
TimeAboveLimit( variable = NULL, window = NULL, limit = NULL, strictly = FALSE, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )TimeAboveLimit( variable = NULL, window = NULL, limit = NULL, strictly = FALSE, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
limit |
the limit to compare the variable against |
strictly |
whether the variable must be strictly above the limit |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class time_above_limit_metric
Time below a certain limit.
TimeBelowLimit( variable = NULL, window = NULL, limit = NULL, strictly = FALSE, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )TimeBelowLimit( variable = NULL, window = NULL, limit = NULL, strictly = FALSE, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
limit |
the limit to compare the variable against |
strictly |
whether the variable must be strictly below the limit |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class time_below_limit_metric
Filter CAMPSIS dataset based on min and max time.
timerange( x, min = 0, max = Inf, exclmin = FALSE, exclmax = FALSE, rebase = FALSE )timerange( x, min = 0, max = Inf, exclmin = FALSE, exclmax = FALSE, rebase = FALSE )
x |
CAMPSIS/NONMEM dataframe |
min |
min time |
max |
max time |
exclmin |
exclude min time when filtering |
exclmax |
exclude max time when filtering |
rebase |
rebase first time to origin, logical value, FALSE by default |
dataset subset
Create a time window object.
TimeWindow( start = 0, end = "last", time_unit = "hour", exclude_start = FALSE, exclude_end = FALSE )TimeWindow( start = 0, end = "last", time_unit = "hour", exclude_start = FALSE, exclude_end = FALSE )
start |
start time of window |
end |
end time of window, use 'last' to specify the end of the simulation output |
time_unit |
time unit of 'start' and 'end' |
exclude_start |
exclude start time when filtering |
exclude_end |
exclude end time when filtering |
a time range object
Tmax.
Tmax( variable = NULL, window = NULL, rebase = TRUE, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Tmax( variable = NULL, window = NULL, rebase = TRUE, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
rebase |
rebase time according to start time of window |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class tmax_metric
Tmin.
Tmin( variable = NULL, window = NULL, rebase = TRUE, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )Tmin( variable = NULL, window = NULL, rebase = TRUE, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
rebase |
rebase time according to start time of window |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class tmin_metric
Gtsummary to Gt.
toGt( x, title = NULL, subtitle = NULL, opts = list(), subscripts = FALSE, fmt_markdown = FALSE )toGt( x, title = NULL, subtitle = NULL, opts = list(), subscripts = FALSE, fmt_markdown = FALSE )
x |
gtsummary table |
title |
table title |
subtitle |
table subtitle |
opts |
gt tab options |
subscripts |
use subscripts |
fmt_markdown |
transform any markdown-formatted text, logical value. Default is FALSE. |
a gt table object
Calculate Area Under the Curve Using Trapezoids.
trap(x, y, method = 1)trap(x, y, method = 1)
x |
x variable, i.e. time |
y |
y variable, i.e. concentration |
method |
method: * 1: linear up - linear down * 2: linear up - logarithmic down * 3: linear before Tmax, logarithmic after Tmax |
Calculates AUC using the trapezoidal method. Assumes data represent a single profile. Despite choice of method, only linear interpolation is used for areas of intervals beginning or ending with y: 0.
area (length-one numeric)
Undefined NCA options.
UndefinedNCAOptions()UndefinedNCAOptions()
an object of class undefined_nca_options
Create an undefined time window.
UndefinedTimeWindow()UndefinedTimeWindow()
undefined time window
Value at (value at specific time).
ValueAt( variable = NULL, window = NULL, time = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )ValueAt( variable = NULL, window = NULL, time = NULL, name = NULL, unit = NULL, stat_display = NULL, digits = NULL )
variable |
dependent variable |
window |
time window on which this metric should be computed |
time |
what time to read the values. If not provided, last values from x will be returned. |
name |
custom metric name (will be exported into table headers) |
unit |
metric unit (will be exported into table headers if provided) |
stat_display |
statistics display, default is '{median} [{p5}-{p95}]' for continuous data or '{n} / {N} ({p}%)' for categorical data |
digits |
rounding digits definitions (integer, function, purrr-style lambda function or list of these, 1 item per statistic), see README |
an object of class value_at_metric