Typical modularization of R code is done through packages. However, packages have a few design limitations that prevents their widespread use by developers.
- Packages do not solve the problem of hierarchical namespacing. In particular, languages like Ruby have good support for a primitive called a module and C++ has a primitive termed a namespace; R, despite being a functional language with roots to the LISP currently does not have a good hierachical namespacing system.
- Hierarchical file structures and exports. In particular, R packages are limited to flat directory structures for historical reasons decided by the R core team.
Both of these limitations are legitimate problems because organizing large codebases managed by teams of dozens or hundreds of developers is difficult or unpleasant without a sane hierarchical namespacing system.
Modules aim to partially allay this problem by building a hierarchical namespacing mechanism on top of environments, a well-defined and well-understood primitive data structure in R.