Replace safely() with possibly()
Once you have figured out how to solve an issue with safely()
, (e.g., output an NA
in place of an error), swap out safely()
with possibly()
. possibly()
will run through your code and implement your desired changes without printing out the error messages.
You'll now map()
over log()
again, but you will use possibly()
instead of safely()
since you already know how to resolve your errors.
Diese Übung ist Teil des Kurses
Foundations of Functional Programming with purrr
Anleitung zur Übung
map()
over the list provided to take thelog()
of each element, usingpossibly()
.- Use
NA_real_
to fix any elements that are not the right data type.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Take the log of each element in the list
list(1, "I can", 10, 0, "purrr") %>%
map(___(function(___){
log(___)
}, ___))