Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Strings basics
Regular expressions
Modifying strings


There are two other useful functions: all() and any(). They are logical functions which summarize the vector of logical values into one value:

  • any() will check if any value in the vector is TRUE.
  • all() will check if all values in the vector are TRUE.

They accept a vector of TRUEs and FALSEs, and return one value: TRUE or FALSE. Look at the examples:

> # Do all values in the mails vector have the "at" sign?
> all(grepl("@", mails))
[1] TRUE
> # Is there anyone in the names vector who has an apostrophe in their name?
> any(grepl("'", names))


Check if we've got any country in the countries vector that contains "x" in its name.