# NOT RUN {
library(tibble)
library(dplyr)
library(tidyr)
library(collateral)
list("a", 10, 100) %>% map_safely(log) %>% has_errors()
list(5, -12, 103) %>% map_quietly(log) %>% has_warnings()
# if you're working with list-columns, the tally functions are useful
# in conjunction with dplyr::summarise()
mtcars %>%
rownames_to_column(var = "car") %>%
as_tibble() %>%
select(car, cyl, disp, wt) %>%
# spike some rows in cyl == 4 to make them fail
mutate(wt = dplyr::case_when(
wt < 2 ~ -wt,
TRUE ~ wt)) %>%
# nest and do some operations quietly()
nest(data = -cyl) %>%
mutate(qlog = map_quietly(data, ~ log(.$wt))) %>%
filter(has_warnings(qlog))
# }
Run the code above in your browser using DataLab