Applying a Function over an Object in R Programming - sapply() Function Last Updated : 19 Jun, 2020 Comments Improve Suggest changes Like Article Like Report 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: Python3 # R program to illustrate # sapply function # Getting the value of Biochemical oxygen # demand data set BOD # Calling sapply() function which # will sum the data of each columns # of BOD sapply(BOD, sum) 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: Python3 # R program to illustrate # sapply function # Initializing a list mylist <- list(c(1, 2, 3, 4), c(2, 4, 6, 8), c(1, 3, 5, 7)) # Calling the sapply() function which # will calculate mean of each vector elements sapply(mylist, mean) Output: [1] 2.5 5.0 4.0 Comment More infoAdvertise with us Next Article Applying a Function over an Object in R Programming - sapply() Function K Kanchan_Ray Follow Improve Article Tags : R Language R DataFrame-Function R Vector-Function R Object-Function R Matrix-Function R List-Function +2 More Similar Reads Apply a Function over a Ragged Array in R Programming - tapply() Function tapply() function in R Language is used to apply a function over a subset of vectors given by a combination of factors Syntax: tapply(vector, factor, fun) Parameters: vector: Created Vector factor: Created Factor fun: Function to be applied Example 1: Python3 1== # R Program to apply a function # ov 1 min read Recursively apply a Function to a List in R Programming - rapply() function rapply() function in R Language is used to recursively apply a function to a list. Syntax: rapply(object, f, classes = "ANY", deflt = NULL, how = c("unlist", "replace", "list")) Parameters: object: represents list or an expression f: represents function to be applied recursively classes: represents 3 min read Concatenating Objects in R Programming - combine() Function In R programming, coercion function c() and combine() function are similar to each other but are different in a way. combine() functions acts like c() and unlist() functions but uses consistent dplyr coercion rules. Moreover, combine() function is used to combine factors in R programming. In this ar 2 min read Convert an Object to List in R Programming - as.list() Function as.list() function in R Programming Language is used to convert an object to a list. These objects can be Vectors, Matrices, Factors, and dataframes. Syntax: as.list(object) Parameters: object: Vector, Matrix, factor, or data frame R - as.list() Function ExampleExample 1: Converting Vector to list 2 min read Display the internal Structure of an Object in R Programming - str() Function str() function in R Language is used for compactly displaying the internal structure of a R object. It can display even the internal structure of large lists which are nested. It provides one liner output for the basic R objects letting the user know about the object and its constituents. It can be 3 min read Like