Use sapply(), lapply(), vapply() when th …


suspensively Use sapply(), lapply(), vapply() when the data is data frame or list and use apply() when the data is matrix. Because matrix does not have the “direction”, e.g., row-wise or column-wise, to apply the function. So it has to be explicitly given.
apply(data, 2, FUN) # for example, column-wise application of the FUN


Leave a Reply

Your email address will not be published. Required fields are marked *