Functional Programming in R

Extends functional programming in R by providing support to the usual higher order functional suspects (Map, Reduce, Filter, etc.).


functools

Build Status Build status codecov.io CRAN_Status_Badge Downloads from the RStudio CRAN mirror Project Status: Active - The project has reached a stable, usable state and is being actively developed.

functools extends functional programming in R. It accomplishes several goals:

  • Add support to the usual higher order functional suspects (Filter(), Map(), Reduce(), etc.) with higher order functions (Compose(), Memoise(), Partial(), Reject(), Fail_With(), Reduce_Right(), All(), Any(), and Best()).

  • Supply higher order function generators (Andify(), Orify()) to make composing predicate functions easier.

  • Provide wrappers (Apply(), Lapply(), Mapply(), Sapply(), Tapply(), and Vapply()) around their respective base R functionals to create an API with consistent naming convention, positional arguments, and argument names.

  • Implement common constants as functions (True(), False(), Identity(), Null(), Na()) for point-free programming.

  • Extend abstract concepts of existiness and truthiness through functions (Existy(), Truthy()).

functools achieves these goals through three main types of function design patterns:

  • Closures (functions that take data and return functions)

  • Functionals (functions that take functions and return data)

  • Function Operators (functions that take functions and return functions)

Installation

You can install:

  • the latest released version from CRAN with

    install.packages("functools")
  • the latest development version from github with

    if (packageVersion("devtools") < 1.6) {
      install.packages("devtools")
    }
    devtools::install_github("paulhendricks/functools")

If you encounter a clear bug, please file a minimal reproducible example on github.

News

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("functools")

0.2.0 by Paul Hendricks, 4 years ago


https://github.com/paulhendricks/functools


Report a bug at https://github.com/paulhendricks/functools/issues


Browse source code at https://github.com/cran/functools


Authors: Paul Hendricks [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Suggests testthat, memoise, pryr


See at CRAN