Learn R Programming

campsis

Requirements

  • R package campsismod must be installed beforehand
  • Simulation engine must be installed too (rxode2 or mrgsolve)

Installation

Install the latest stable release using devtools:

devtools::install_github("Calvagone/campsis")

Basic example

Import the campsis package:

library(campsis)

Create your dataset:

ds <- Dataset(50) %>%
  add(Bolus(time = 0, amount = 1000, ii = 12, addl = 2)) %>%
  add(Observations(times = seq(0, 36, by = 0.5)))

Load your own model or use a built-in model from the library:

model <- model_suite$pk$`2cpt_fo`

Simulate your results with your preferred simulation engine (rxode2 or mrgsolve):

results <- simulate(model = model, dataset = ds, dest = "mrgsolve", seed = 1)

Plot your results:

shaded_plot(results, "CONC")

Copy Link

Version

Install

install.packages('campsis')

Monthly Downloads

390

Version

1.9.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Nicolas Luyckx

Last Published

August 5th, 2026

Functions in campsis (1.9.0)

StatsOutfun

Create a statistics output function
Scenarios

Create a list of scenarios.
RepeatAtSchedule

'Repeat at' schedule constructor. Note that the time 0 for the base pattern will be added by default if not provided.
Settings

Create advanced simulation settings.
TimeSequence

Instantiate a new time sequence.
Scenario

Create an scenario.
apply_outfun

Apply output function(s) on the given Campsis results.
arm-class

Arm class.
apply_action

Apply some action on the given object.
TimeVector

Instantiate a new time vector
UniformDistribution

Create an uniform distribution.
as.numeric,time_vector-method

Time vector to numeric vector.
as.numeric,time_sequence-method

Time sequence to numeric vector.
check_ii_and_addl

Check ii and addl arguments in addition to time.
bolus-class

Bolus class.
bootstrap-class

Bootstrap class.
bootstrap_distribution-class

Bootstrap distribution class.
arms-class

Arms class.
campsis_tbl-class

Campsis table class (see this class as an interface)
bolus_wrapper-class

Bolus wrapper class.
apply_compartment_characteristics

Apply compartment characteristics from model. In practice, only compartment infusion duration needs to be applied.
binomial_distribution-class

Binomial distribution class.
campsis_handler

Suggested Campsis handler for showing the progress bar.
assign_dose_number

Assign dose number to each treatment entry.
TimeVaryingCovariate

Create a time-varying covariate. This covariate will be implemented using EVID=2 rows in the exported dataset and will not use interruption events.
apply_scenario

Apply scenario to the given model or dataset.
convert_time

Convert numeric time vector based on the provided units.
constant_distribution-class

Constant distribution class.
compute_pi

Compute the prediction interval summary over time.
compute_stats

Compute generic statistics over time.
campsis_metadata-class

Campsis metadata class.
default_outfun-class

Default output function class.
discrete_distribution-class

Discrete distribution class.
dataset-class

Dataset class.
days

Convert days to hours.
covariate-class

Covariate class.
covariates-class

Covariates class.
dataset_config-class

Dataset configuration class.
counterBalanceLocfMode

Counter-balance LOCF mode for occasions & IOV. This function will simply shift all the related occasion & IOV columns to the left (by one).
counterBalanceNocbMode

Counter-balance NOCB mode for occasions & IOV. This function will simply shift all the related occasion & IOV columns to the right (by one).
compute_incremental_progress

Compute incremental progress.
default_settings-class

Default settings class.
cutTableForEvent

Cut table according to given iteration.
convertTime

Convert numeric time vector based on the provided units.
distribution-class

Distribution class. See this class as an interface.
declare_settings-class

Declare settings class.
cyclic_schedule-class

Cyclic schedule class.
dosing_only

Filter Campsis output on dosing rows.
dose_adaptation-class

Dose adaptation class.
.auto_strata

Detect VPC stratification variable automatically.
drop_others

Return the 'DROP_OTHERS' string that may be used in the 'outvars' vector for RxODE/mrgsolve to drop all others variables that are usually output in the resulting data frame.
.auto_colour_columns

Detect colour stratification columns automatically.
.assert_variable_present

Assert that one or more variable columns are present in the data.
events-class

Events class.
event_covariate-class

Event covariate class.
generate_iiv

Generate IIV matrix for the given Campsis model.
fixed_distribution-class

Fixed distribution class.
dosing_schedule-class

Dosing schedule class.
fillIOVOccColumns

Fill IOV/Occasion columns.
event-class

Event class.
dose_adaptations-class

Dose adaptations class.
fixed_covariate-class

Fixed covariate class.
get_covariates

Get all covariates (fixed / time-varying / event covariates).
get_campsis_option

Get Campsis option logic.
generate_iiv_

Generate IIV matrix for the given OMEGA matrix.
get_available_time_units

Return the list of available time units.
.is_replicated

Does the data contain more than one replicate?
export_delegate

Export delegate method. This method is common to RxODE and mrgsolve.
getDatasetMaxTime

Get dataset max time.
get_campsis_options

Get the Campsis options (R options).
function_distribution-class

Function distribution class.
get_event_covariates

Get all event-related covariates.
export_table_delegate

Export table delegate.
getEventIterations

Get list of event iterations.
get_compartment_mapping

Get a mapping table with all possibilities of compartment names and their indexes knowing that compartment names can be provided as character or as integer.
get_fixed_covariates

Get all fixed covariates.
get_occasions

Get all occasions.
get_iovs

Get all IOV objects.
get_initial_conditions

Get initial conditions at simulation start-up.
get_seed_for_iteration

Get seed for iteration.
get_simulation_engine_type

Get simulation engine type.
get_seed

Get seed value.
get_random_seed_value

Get random seed value.
internal_settings-class

Internal settings class (transient object from the simulation settings).
get_splitting_configuration

Get splitting configuration for parallel export.
infusion_wrapper-class

Infusion wrapper class.
hours

Convert hours to hours (do nothing).
is_empty_bootstrap

Is the given bootstrap empty.
get_seed_for_parameters_sampling

Get seed for parameter uncertainty sampling.
getTimeVaryingVariables

Get all time-varying variables. These variables are likely to be influenced by the NOCB mode chosen and by the 'nocbvars' vector.
get_column

Get data of given column unless if does not exist (return NULL in that case).
get_seed_for_dataset_export

Get seed for dataset export.
infusion-class

Infusion class.
hardware_settings-class

Hardware settings class.
get_times

Get all distinct times for the specified object.
get_time_varying_covariates

Get all time-varying covariates.
length,dataset-method

Return the number of subjects contained in this dataset.
length,repeat_at_schedule-method

Return the number of repetition cycles.
import_campsismod_to_namespace

Import the whole campsismod package into NAMESPACE when parsed by 'roxygen'.
mergeTimeVaryingCovariates

Merge time-varying covariates into a single data frame. This last data frame will be merged afterwards with all treatment and observation rows.
length,arm-method

Return the number of subjects contained in this arm.
length,cyclic_schedule-method

Return the number of repetition cycles.
lognormal_distribution-class

Log normal distribution class.
normal_distribution-class

Normal distribution class.
obs_only

Filter Campsis output on observation rows.
minutes

Convert minutes to hours.
nocb_settings-class

NOCB settings class.
left_join_iiv

Left-join IIV matrix.
json_to_campsis_dataset

JSON to Campsis dataset.
json_to_campsis_settings

JSON to Campsis dataset.
observations_set-class

Observations set class.
observations-class

Observations class.
mrgsolve_engine-class

mrgsolve engine class.
months

Convert pharma months (1 month = 4 weeks) to hours.
make_vpc_summary

Make the VPC summary. Input data frame must contain the following columns: - replicate: replicate number - low: low percentile value in replicate (and in scenario if present) - med: median value in replicate (and in scenario if present) - up: up percentile value in replicate (and in scenario if present) - any scenario column
nhanes

NHANES database (demographics and body measure data combined, from 2017-2018).
occasion-class

Occasion class.
pi_outfun-class

Prediction interval output function class.
pi_campsis_tbl-class

Prediction Interval (PI) Campsis table class
occasions-class

Occasions class.
on_cran

Check if the current session is on CRAN. The objective is to potentially suppress long tasks to be run on CRAN (long tests or vignettes).
preprocessNocbvars

Preprocess 'nocbvars' argument.
on_ci

Check if the current session is on CI (e.g. GitHub actions).
outfun-class

Output function class.
outfuns-class

Output functions class (i.e. a collection of output functions).
nca_table_outfun-class

NCA table output function class.
open_json

Open JSON file.
preprocess_outfun

Pre-process outfun argument.
preprocess_dest

Pre-process destination engine. Throw an error message if the destination engine is not installed.
preprocess_scenarios

Pre-process scenarios.
preprocess_outvars

Preprocess 'outvars' argument. 'Outvars' is a character vector which tells Campsis the mandatory columns to keep in the output dataframe.
preprocess_arm_column

Preprocess ARM column. Add ARM equation in model automatically.
preprocess_replicates

Preprocess 'replicates' argument.
preprocess_dosing

Preprocess 'dosing' argument.
preprocess_events

Pre-process events.
preprocessTSLDAndTDOSColumn

Preprocess TSLD and TDOS columns according to given dataset configuration.
preprocess_ids

Preprocess subjects ID's.
protocol-class

Protocol class.
processAllTimeColumns

Process time-related columns according to given dataset configuration.
progress_settings-class

Progress settings class.
repeat_at_schedule-class

'Repeat at' schedule class.
sample

Sample generic object.
process_arm_labels

Process arm labels. Arm identifiers in ARM column are replaced by arm labels as soon as one arm label is provided.
repeat_schedule

Repeat schedule.
replace_action-class

Replace action class.
rxode_engine-class

rxode2 engine class.
repeated_schedule-class

Repeated schedule class. See this class as an interface.
retrieve_parameter_value

Retrieve the parameter value (standardized) for the specified parameter name.
preprocess_settings

Preprocess the simulation settings.
remove_initial_conditions

Remove initial conditions.
sample_covariates_list

Sample covariates list.
preprocess_slices

Preprocess 'slices' argument.
reorder_columns

Reorder output columns.
process_drop_others

Process 'DROP_OTHERS'.
preprocess_tablefun

Pre-process tablefun argument.
scenario_action-class

Scenario action class.
seconds

Convert seconds to hours.
scenario_actions-class

Scenario actions class.
scatter_plot.std_campsis_tbl

Scatter plot for standard Campsis simulation output.
scatter_plot

Scatter plot (S3 generic).
scenarios-class

Scenarios class.
scenario-class

Scenario class.
scatterPlot

Scatter plot (or X vs Y plot).
setLabel

Set the label.
process_simulate_arguments

Preprocess arguments of the simulate method.
sample_distribution_as_tibble

Sample a distribution and return a tibble.
sampleTimeVaryingCovariates

Sample time-varying covariates.
set_label

Set the label.
setup_plan_default

Setup default plan for the given simulation or hardware settings. This plan will prioritise the distribution of workers in the following order: 1) Replicates (if 'replicate_parallel' is enabled) 2) Scenarios (if 'scenario_parallel' is enabled) 3) Dataset export / slices (if 'dataset_export' or 'slice_parallel' is enabled)
setup_plan_sequential

Setup plan as sequential (i.e. no parallelisation).
set_seed

Set the seed. The goal of this method is to centralize all calls to the R method 'set.seed'.
setupPlanSequential

Setup plan as sequential (i.e. no parallelisation).
setupPlanDefault

Setup default plan for the given simulation or hardware settings. This plan will prioritise the distribution of workers in the following order: 1) Replicates (if 'replicate_parallel' is enabled) 2) Scenarios (if 'scenario_parallel' is enabled) 3) Dataset export / slices (if 'dataset_export' or 'slice_parallel' is enabled)
shadedPlot

Shaded plot (or prediction interval plot).
setSubjects

Set the number of subjects.
shaded_plot

Shaded plot / prediction interval plot (S3 generic).
set_subjects

Set the number of subjects.
spaghettiPlot

Spaghetti plot.
simulation_engine-class

Simulation engine class.
simulate_scenarios

Simulation scenarios.
solver_settings-class

Solver settings class. See ?mrgsolve::update. See ?rxode2::rxSolve.
simulation_progress-class

Simulation progress class.
simulation_settings-class

Simulation settings class.
simulate

Simulate function.
shaded_plot.std_campsis_tbl

Shaded plot for standard Campsis simulation output.
std_campsis_tbl-class

Standard Campsis table class
spaghetti_plot

Spaghetti plot (S3 generic).
simulate_delegate

Simulation delegate (several replicates).
simulate_delegate_core

Simulation delegate core (single replicate).
stats_campsis_tbl-class

Statistics Campsis table class
stats_outfun-class

Statistics output function class.
undefined_distribution-class

Undefined distribution class. This type of object is automatically created in method to_explicit_distribution() when the user does not provide a concrete distribution. This is because S4 objects do not accept NULL values.
time_sequence-class

Time sequence class.
treatment_iovs-class

Treatment IOV's class.
standardise_time

Standardise time to hours.
splitDataset

Split dataset according to config.
time_vector-class

Time vector class.
unwrap_treatment

Unwrap treatment.
treatment-class

Treatment class.
treatment_iov-class

Treatment IOV class.
spaghetti_plot.std_campsis_tbl

Spaghetti plot for standard Campsis simulation output.
time_varying_covariate-class

Time-varying covariate class.
unite_columns

Unite the given column names.
to_explicit_distribution

Convert user-given distribution to an explicit Campsis distribution. Passed distribution can be: - a NULL value. In that case, it will be converted into an 'UndefinedDistribution'. - a single numeric value. In that case, it will be converted into a 'ConstantDistribution'. - a numeric vector. In that case, it will be converted into a 'FixedDistribution'. - all available types of distribution. In this case, no conversion is applied.
toDatasetSummary

Convert dataset to dataset summary (internal method).
undefined_schedule-class

Undefined schedule class.
uniform_distribution-class

Uniform distribution class.
update_addl

Update the number of additional doses (ADDL).
weeks

Convert weeks to hours.
vec_restore.campsis_tbl

Restore a campsis_tbl object
vpc_plot.std_campsis_tbl

VPC plot for standard Campsis simulation output.
vpc_plot.pi_campsis_tbl

VPC plot for prediction-interval Campsis output.
vpc_plot

VPC plot (S3 generic).
update_ii

Update the inter-dose interval (II).
update_repeat

Update the repeat field (argument 'rep' in Bolus and Infusion constructors).
years

Convert pharma years (1 year = 12*4 weeks) to hours.
update_amount

Update amount.
vpcPlot

VPC plot.
BinomialDistribution

Binomial distribution.
Dataset

Create a dataset.
ConstantDistribution

Create a constant distribution. Its value will be constant across all generated samples.
Bolus

Create one or several bolus(es).
BootstrapDistribution

Create a bootstrap distribution. During function sampling, Campsis will generate values depending on the given data and arguments.
DatasetConfig

Create a dataset configuration. This configuration allows Campsis to know which are the default depot and observed compartments.
CyclicSchedule

Cyclic schedule constructor.
Covariate

Create a non time-varying (fixed) covariate.
Arm

Create a treatment arm.
Bootstrap

Create a bootstrap object.
DefaultOutfun

Default output function (identity function).
DefaultSettings

Create default settings.
DoseAdaptation

Create a dose adaptation.
DiscreteDistribution

Discrete distribution.
DatasetSummary

Create a dataset summary (internal method).
Declare

Create declare settings.
EventRelatedObservations

Create an event-related observations list. Please note that the provided 'times' will automatically be sorted. Duplicated times will be removed.
Events

Create a list of interruption events.
EventCovariate

Create an event covariate. These covariates can be modified further in interruption events.
Event

Create an interruption event.
FunctionDistribution

Create a function distribution. During distribution sampling, the provided function will be responsible for generating values for each sample. If first argument of this function is not the size (n), please tell which argument corresponds to the size 'n' (e.g. list(size="n")).
FixedDistribution

Create a fixed distribution. Each sample will be assigned a fixed value coming from vector 'values'.
Hardware

Create hardware settings.
NOCB

Create NOCB settings.
EventIteration

Create an event iteration object.
Progress

Create progress settings.
Outfuns

Create a collection of output functions.
NormalDistribution

Create a normal distribution.
Outfun

Create a new output function
LogNormalDistribution

Create a log normal distribution.
Observations

Create an observations list. Please note that the provided 'times' will automatically be sorted. Duplicated times will be removed.
Infusion

Create one or several infusion(s).
IOV

Define inter-occasion variability (IOV) into the dataset. A new variable of name 'colname' will be output into the dataset and will vary at each dose number according to the given distribution.
EtaDistribution

Create an ETA distribution. The resulting distribution is a normal distribution, with mean=0 and sd=sqrt(OMEGA).
DosingSchedule

Dosing schedule constructor.
NCATableOutfun

Create a NCA table output function
ParameterDistribution

Create a parameter distribution. The resulting distribution is a log-normal distribution, with meanlog=log(THETA) and sdlog=sqrt(OMEGA).
SimulationProgress

Create a simulation progress object.
ReplaceAction

Create a replace action.
PIOutfun

Create a prediction interval output function
PI

Compute the prediction interval summary over time (deprecated).
Solver

Create solver settings.
Occasion

Define a new occasion. Occasions are defined by mapping occasion values to dose numbers. A new column will automatically be created in the exported dataset.