How to use sapply in r?



How to use sapply in r?..

Answer / Ashish Khare

sapply is a function from the base R package that applies a function to each element of an object (like a list or vector) and returns a simplified result. For example, sapply(c(1, 2, 3), function(x) x^2) will return a vector containing the squares of the numbers 1, 2, and 3.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More R Programming Interview Questions

How will you merge two dataframes in r programming language?

1 Answers  


What is correlation? How would you measure correlation in r?

1 Answers  


How can you simulate random walk model using r?

1 Answers  


What does the term 'dreaded for loop' means?

1 Answers  


Which function is used to create a histogram visualisation in r programming language?

1 Answers  


Name some functions available in “dplyr” package.

1 Answers  


What is data structure in r?

1 Answers  


What is the purpose of using Next statement in R language?

1 Answers  


What is the use of stringr package. Give some examples of the functions in stringr.

1 Answers  


What are programming features of R?

1 Answers  


What is the use of subset() function and sample() function in R ?

1 Answers  


What is SAS and SPSS in R?

1 Answers  


Categories