![]() |
VOOZH | about |
apply() function in R Language is used to perform mathematical operations across elements of an array or a matrix.
Syntax: apply(x, margin, func) Parameters: x: Array or matrix margin: dimension on which operation is to be applied func: operation to be appliedExample 1: Output:
[, 1] [, 2] [, 3] [1, ] 1 4 7 [2, ] 2 5 8 [3, ] 3 6 9 [1] 12 15 18 [1] 6 15 24Example 2: Output:
[, 1] [, 2] [, 3] [1, ] 1 4 7 [2, ] 2 5 8 [3, ] 3 6 9 [1] 28 80 162 [1] 6 120 504