Aan de slagGa gratis aan de slag

What is a predicate?

A predicate function is "a function that either returns TRUE or FALSE." While a predicate functional "takes a vector and a predicate function and do something useful."***

In other words, the predicate functionals take in .x, which is a vector, a dataframe, or a list, and test the predicate on every element of .x. For example, you can test if every element is numeric with the is.numeric() predicate from R-Base, or if the mean of some elements is under 5 with this mapper: ~mean(.x) < 5.

Which of these functions is NOT a predicate?

Deze oefening maakt deel uit van de cursus

Intermediate Functional Programming with purrr

Cursus bekijken

Praktische interactieve oefening

Zet theorie om in actie met een van onze interactieve oefeningen.

Begin met trainen