Returns a logical vector indicating which elements contain a type of side effect. If you have a large data frame or list, you can use this to isolate the element that contain warnings, for example, or messages.s

has_results(x)

has_errors(x)

has_warnings(x)

has_messages(x)

has_output(x)

Arguments

x

A safely_mapped or quietly_mapped list to tally.

Value

A logical vector, of the same length as x, which is TRUE for elements that contain a type of side effect and FALSE otherwise.

Details

The has_*() functions power the `tally_*()`` functions and, in turn, the summary() method.

Examples

library(tibble) library(dplyr) library(tidyr) library(collateral) list("a", 10, 100) %>% map_safely(log) %>% has_errors()
#> [1] TRUE FALSE FALSE
list(5, -12, 103) %>% map_quietly(log) %>% has_warnings()
#> [1] FALSE TRUE FALSE
# 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))
#> # A tibble: 1 x 3 #> cyl data qlog #> <dbl> <list> <collat> #> 1 4 <tibble [11 × 3]> R _ _ W