What does loop function signifies in R

r

#1

while studying I came across to four loop function
1-lapply
2-tapply
3-sapply
4-apply
I want to know what each loop function means and where to use them


#2

see here

https://stat.ethz.ch/R-manual/R-devel/library/base/html/lapply.html

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.

also see here


#3

The R manuals are indeed helpful but you can find some very good examples here:

and here:

Hope this helps!