# Examples of Predicate Functionals

## Master R

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”, you can buy it from Amazon or read it online for FREE.