Skip to content

R6 encapsulated OOP base classes for simulation modeling studies in R

License

Notifications You must be signed in to change notification settings

RANDCorporation/R6Sim

Repository files navigation

R6Sim

R-CMD-check

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.

Why R6Sim

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.

Installation

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)

Usage

See the introductory vignette:

vignette("introduction", package = "R6Sim")

Contact

Reach out to Pedro Nascimento de Lima for questions related to this repository.

License

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.

About

R6 encapsulated OOP base classes for simulation modeling studies in R

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages