Question: Consider the list created below. Write a short script using lapply() to test which elements in the list are functions. Then return only those list
Consider the list created below. Write a short script using lapply() to test which elements in the list are functions. Then return only those list elements which are functions. Make sure that the function you create will work with arbitrary lists. It is not acceptable to just figure out yourself which elements contain functions and subset bigList below. Make it automated and flexible.
```{r} bigList <- list(x = 1:8, y = data.frame(norm = rnorm(5, 0, 1)), z = function(x) {x}, t1 = function(x, y) {x + y ^ exp(x)}, char = "This is a character", t2 = function(lambda) {lambda ^ (1 / pi)}) bigList ```
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
