R6Sim
provides an R6
base class for simulation modeling analyses
using the structure of encapsulated object-oriented programming provided
by R6
. This package allows one to create models that inherit R6Sim
,
and specify models and experimental designs that can use multiple models
using the R6Experiment
class.
Simulation modeling projects performed in R often rely on poorly-designed code bases, where the modeler and others don’t have visibility into what the model does and all the inputs the model needs to run. Often, there is a tight dependence on inputs that may live in the global environment, or the modeler tends to add a large set of function parameters that percolate through the code and are passed through several layers of functions. This can be problematic when one simply wants to inspect the totality of the inputs that are influencing model outputs, but those inputs live at several layers in the code.
One potential cause of those problems is the overuse of the functional
programming paradigm in cases where an encapsulated object-oriented
paradigm could be helpful. After building models in R for a few years, I
arrived at this simple pattern where the model is an R6
class, and
there is another class (which I call an experiment), that can include
one or more models, and can run those models. R6Sim
is a package
that helps implement this modeling pattern.
You can install R6Sim
like so:
# install the remotes package if you do not have it
# install.packages("remotes")
# install from github:
remotes::install_github("randcorporation/r6sim",build_vignettes = T)
See the introductory vignette:
vignette("introduction", package = "R6Sim")
Reach out to Pedro Nascimento de Lima for questions related to this repository.
Copyright (C) 2024 by The RAND Corporation. This repository is released as open-source software under a GPL-3 license. See the LICENSE.md file.