How to use sapply() in R? Explain with an example
Sapply() takes list as an input but returns an output as vectors.Let us explain with an example
x <- list(a = 1, b = 1:3, c = 10:100)
#Compare with above; a named vector, not a list
sapply(x, FUN = length)
a b c
1 3 91
sapply(x, FUN = sum)
a b c
1 6 5005