View source: R/discard_errors.R
discard_errors | R Documentation |
purrr::safely
.Used in scrapping, when swim_parse
is applied over a list of results
using purrr::map
the result is a list of two element lists. The first
element is the results, the second element is an error register. This
function removes all elements where the error register is not NULL, and then
returns the results (first element) of the remaining lists.
discard_errors(x)
x |
a list of lists from |
a list of lists where sub lists containing a non-NULL error have been discarded and error elements have been removed from all remaining sub lists
result_1 <- data.frame(result = c(1, 2, 3))
error <- NULL
list_1 <- list(result_1, error)
names(list_1) <- c("result", "error")
result_2 <- data.frame(result = c(4, 5, 6))
error <- "result is corrupt"
list_2 <- list(result_2, error)
names(list_2) <- c("result", "error")
list_of_lists <- list(list_1, list_2)
discard_errors(list_of_lists)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.