Why you should use vapply in R
In this post we'll cover the vapply function in R. vapply is generally lesser known than the more popular sapply, lapply, and apply functions. However, it is very useful when you know what data type you're expecting to apply a function to as it helps to prevent silent errors. Because of this, it can be more advisable to use vapply rather than sapply or lapply. See more R articles by clicking here Examples Let's take the following example. Here, we have a list of numeric vectors and we want to get the max value of each vector. That's simple enough - we can just use sapply and apply the max function for each vector. [code lang="R"] test <- list(a = c(1, 3, 5), b = c(2,4,6), c = c(9,8,7)) sapply(test,…