Loading…
useR!2017 has ended
Friday, July 7 • 11:18am - 11:36am
Modules in R

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
Keywords: programming, functional-programming
Webpages: https://CRAN.R-project.org/package=modules, https://github.com/wahani/modules
In this talk I present the concept of modules inside the R language. The key idea of the modules package is to provide a unit of source code which is self contained, i.e. has it’s own scope. The main and most reliable infrastructure for such organisational units of source code is a package. Compared to a package modules can be considered ad-hoc, but still self contained. That means they come with a mechanism to import dependencies and also to export member functions. However, modules do not act as replacements for packages. Instead they are a unit of abstraction in between functions and packages.
There are two use cases in which modules can be beneficial. First when we write scripts and want to use sourced functions or, in general, need more control of the enclosing environment of a function. Here we may be interested to be able to state the dependencies of a function close to its definition; and also without the typical side effects to the global environment of the current R session. Second, as an organisational unit inside packages. Here modules can act as similar entities as objects in object-oriented-programming. However, other languages with similar concepts are mostly functional and the design borrows from languages like julia, Erlang and F#. As a result modules are not designed to contain data. Furthermore there is no formal mechanism for inheritance. Instead several possibilities for module composition are implemented.



Friday July 7, 2017 11:18am - 11:36am CEST
4.02 Wild Gallery