0 votes
in R Basics by

 What is the difference between sapply and lapply? When should you use one versus the other? Bonus: When should you use vapply?

1 Answer

0 votes
by

Use lapply when you want the output to be a list, and sapply when you want the output to be a vector or a dataframe. Generally vapply is preferred over sapply because you can specify the output type of vapply (but not sapply). The drawback is vapply is more verbose and harder to use.

...