# NOT RUN {
safe_log <- safely(log)
safe_log(10)
safe_log("a")
list("a", 10, 100) %>%
map(safe_log) %>%
transpose()
# This is a bit easier to work with if you supply a default value
# of the same type and use the simplify argument to transpose():
safe_log <- safely(log, otherwise = NA_real_)
list("a", 10, 100) %>%
map(safe_log) %>%
transpose() %>%
simplify_all()
# To replace errors with a default value, use possibly().
list("a", 10, 100) %>%
map_dbl(possibly(log, NA_real_))
# }
Run the code above in your browser using DataLab