![]() |
VOOZH | about |
sapply() function in R Language takes list, vector or data frame as input and gives output in vector or matrix. It is useful for operations on list objects and returns a list object of same length of original set.
Syntax: sapply(X, FUN) Parameters: X: A vector or an object FUN: Function applied to each element of xExample 1: Output:
Time demand 1 1 8.3 2 2 10.3 3 3 19.0 4 4 16.0 5 5 15.6 6 7 19.8 Time demand 22 89Example 2: Output:
[1] 2.5 5.0 4.0