What are major difference between split and loop function in R



During my study of loop function I came across four loop function
and the I came across the term split which is also loop function but I am not able to understand what is difference between split and other loop function and where to use it.


Hey- these are not really loop functions , they are special functions to apply functions. So they are more like replacement for loop

From manual


lapply returns a list of the same length as X, each element of which is the result of applying FUN to the corresponding element of X.

sapply is a user-friendly version and wrapper of lapply by default returning a vector, matrix or, if simplify = “array”, an array if appropriate, by applying simplify2array(). sapply(x, f, simplify = FALSE, USE.NAMES = FALSE) is the same as lapply(x, f).

vapply is similar to sapply, but has a pre-specified type of return value, so it can be safer (and sometimes faster) to use.

replicate is a wrapper for the common use of sapply for repeated evaluation of an expression (which will usually involve random number generation).

simplify2array() is the utility called from sapply() when simplify is not false and is similarly called from mapply().

while split does only splitting the apply family applies function for each member


split divides the data in the vector x into the groups defined by f. The replacement forms replace values corresponding to such a division. unsplit reverses the effect of split.


split(x, f, drop = FALSE, …)