Google News
logo
R - Interview Questions
Advantages of using an applied family of functions in R?
The applied family of functions is a built-in family which appears with the built-in packages in R. It is already installed in it. 
 
It allows us to manipulate data frames, vectors, arrays, etc. It works more effectively than loops and also gives better performance from them which is faster at the execution level. It reduces the need for explicitly creating a loop in R.   
 
The list of the apply family are as follows :
 
apply() function : It helps to apply a function on rows or columns of a data frame. 
Syntax : apply()
 
lapply() function : It takes a list as an argument and applies a function to each element of the list by looping. 
Syntax : lappy()
 
sapply() function : It is more advanced version than lappy() however it works same as lappy(). It also takes a list as an argument and applies a function to each element of the list by looping. The only difference is in output generalization. Where lappy() returns a list as an output every time, sapply returns certain algorithms as output.
Syntax :  sapply()
 
tapply() function : It can be applied to vectors and factors. The data which contain different subgroup and we have to apply a specific function on each subgroup that time we can use it. 
Syntax : tapply()
 
mapply() function : It is a multivariate version of the sapply() function where we apply the same function to multiple arguments.
Syntax : mapply()
Advertisement