Functional Programming with purrr and base R
Functional programming is a programming paradigm that emphasizes immutability, pure functions, and declarative programming, treating computation as the evaluation of mathematical functions and avoiding shared state and side effects. It focuses on composing functions and working with immutable data to create robust and predictable programs. In terms of our day-to-day work, this means focusing on using functions to solve problems and avoiding changing data. We also emphasize writing clear, reusable code that is easier to understand and predictable in its behavior. This style helps us as programmers, especially when code becomes complex or must be maintained over a longer period of time.
R has several base functions, including the apply
family, as well as external packages that support functional programming, including purrr
, and tidyverse
. These tool kits provide functions and operators that facilitate working with data using a functional...