Foundations of Functional Programming with purrr
Auriel Fournier
Instructor
a <- list("unknown", 10) %>%
map(safely(function(x)
x * 10,
otherwise = NA_real_))
[[1]]
[[1]]$result
[1] NA
[[1]]$error
<simpleError in x * 10: non-numeric
argument to binary operator>
[[2]]
[[2]]$result
[1] 100
[[2]]$error
NULL
a <- list("unknown",10) %>%
map(safely(function(x)
x * 10,
otherwise = NA_real_)) %>%
transpose()
$result
$result[[1]]
[1] NA
$result[[2]]
[1] 100
$error
$error[[1]]
<simpleError in x * 10:
non-numeric argument to
binary operator>
$error[[2]]
NULL
...
Foundations of Functional Programming with purrr