6 Predicate functions

Predicate functions are functions that return a single TRUE or FALSE. You use predicate functions to check if your input meets some condition. For example, is.character() is a predicate function that returns TRUE if its input is of type character and FALSE otherwise.

R does not have scalars. "a" is actually a character vector of length 1. is.character() and similar functions return a single value for all vectors, whether they have 1 element or many.

In atomic vectors like x, all the elements must be the same type. The type of the individual elements will always be the same as the type of the atomic vector. You can use the function typeof() to find the type of a vector (or any other object in R).

is.character() simply checks whether x is of type character.

If the vector is not a character vector, is.character() will return FALSE.

Lists can have elements of any type. Even if all the elements of a list are of type character, the list is not a character vector, and is.character() will return FALSE.