The mod package provides a simple way to structure program and data into flexible and independent units for programming and interactive use. Modules indtroduced by the mod package offer merits and conveniences currently absent from R, while keeping R’s authentic flavor.

Why?

Programs need to be oraganized into units.

A package is a very robust solution, but is formal and compliated; packages require additional knowledge to R and must be installed in the local library by install.packages(). On the other hand, simple R scripts, often executed by source(), are brittle and may create namespace conflict; They are unsuitable for building tools.

Modules fills the hollow middleground by allowing programs to live separately and work together at the same time. Each module has its own scope, host is own objects, an can attach different packages without interefering with each other or the global search path. They can be created either inline with other programs or from a standalone file, and can be used in the user’s working environment, as a part of a package, or in other modules.

Installation

Install the published version from CRAN with:

Install the development version from GitHub with:

devtools::install_github("iqis/mod")

Vocabulary

The mod package has a simple UI:

Quickstart

m <- mod::ule({
        numbers <- c(1,2,2,2,3,3,4,5,6)
        numbers_plot <- function(x = numbers) {
                plot(x, col = "purple", pch = 15)
                title("Numbers", ylab = "Value")
        }
})

m$numbers
#> [1] 1 2 2 2 3 3 4 5 6
m$numbers_plot()

Documentation

mod website