In this article, I will demonstrate how to use the apply family of functions in R. They are extremely helpful, as you will see. apply apply can be used to apply a function to a matrix. For example, let’s create a sample dataset: data <- matrix(c(1:10, 21:30), nrow = 5, ncol = 4) data