Apply function to each row in Data.table in R
In this article, we are going to see how to apply functions to each row in the data.table in R Programming Language.
For applying a function to each row of the given data.table, the user needs to call the apply() function which is the base function of R programming language, and pass the required parameter to this function to be applied in each row of the given data.table in R language.
apply() function returns a vector or array or list of values obtained by applying a function to the margins of an array or matrix.
apply(X, MARGIN, FUN, …)
- X: an array, including a matrix.
- MARGIN: a vector giving the subscripts which the function will be applied over.
- FUN: the function to be applied: see ‘Details’. In the case of functions like +, %*%, etc., the function name must be backquoted or quoted.
- …: optional arguments to FUN.
 7 8 10 13 7
 4 3 5 5 5