A predicate is a function that returns a single TRUE or FALSE, for example, is.factor(), all(), or is.NULL(). A predicate functional is a function that applies a predicate to each element of a list or data frame. For example, we can define a predicate functional where() that checks the type of each column in a data frame.
Here’s how you’d use it.
There’re 3 common predicate functionals already defined in base R, namely, Filter(), Find(), Position(). Here’s how you can use them.
This article is inspired by Hadley’s book “Advanced R”, which can be obtained from Amazon.