VOOZH about

URL: https://www.geeksforgeeks.org/r-language/applying-a-function-over-an-object-in-r-programming-sapply-function/

⇱ Applying a Function over an Object in R Programming - sapply() Function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Applying a Function over an Object in R Programming - sapply() Function

Last Updated : 15 Jul, 2025
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 x
Example 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 89
Example 2: Output:
[1] 2.5 5.0 4.0
Comment

Explore