-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to make a safely list output into a datatable #1060
Comments
@jic007 You can do that using items <- list('numbers' = 1:10, 'letters' = letters)
result <-
purrr::map(
items,
purrr::safely(sum)
)
result |>
tibble::enframe() |>
tidyr::hoist(value, 'result', 'error')
#> # A tibble: 2 x 3
#> name result error
#> <chr> <int> <list>
#> 1 numbers 55 <NULL>
#> 2 letters NA <smplErrr> Created on 2023-04-24 with reprex v2.0.2 |
It does bother me that items <- list('numbers' = 1:10, 'letters' = letters)
result <-
purrr::map(
items,
purrr::safely(sum)
)
result |>
tibble::enframe() |>
tidyr::unnest_wider(value)
#> Error in `tidyr::unnest_wider()`:
#> i In column: `value`.
#> i In row: 2.
#> Caused by error in `list_sizes()`:
#> ! `x$error` must be a vector, not a <simpleError/error/condition> object.
#> Backtrace:
#> x
#> 1. +-tidyr::unnest_wider(tibble::enframe(result), value)
#> 2. | \-tidyr:::col_to_wide(...)
#> 3. | +-tidyr:::with_indexed_errors(...)
#> 4. | | \-rlang::try_fetch(...)
#> 5. | | \-base::withCallingHandlers(...)
#> 6. | \-purrr::map(...)
#> 7. | \-purrr:::map_("list", .x, .f, ..., .progress = .progress)
#> 8. | +-purrr:::with_indexed_errors(...)
#> 9. | | \-base::withCallingHandlers(...)
#> 10. | +-purrr:::call_with_cleanup(...)
#> 11. | \-tidyr (local) .f(.x[[i]], ...)
#> 12. | \-tidyr:::elt_to_wide(...)
#> 13. | \-vctrs::list_sizes(x)
#> 14. \-vctrs:::stop_scalar_type(`<fn>`(`<smplErrr>`), "x$error", `<env>`)
#> 15. \-vctrs:::stop_vctrs(...)
#> 16. \-rlang::abort(message, class = c(class, "vctrs_error"), ..., call = vctrs_error_call(call)) Created on 2023-04-24 with reprex v2.0.2 |
I don't think that's an |
how to make a safely list output into a datatable
i am working with a function to copy files using fs::file_copy
The output using safely generates a list of lists containint file path error and status and it would be much easier to dignose issues if i get it in table format. Couldnt figur out how to do it
The text was updated successfully, but these errors were encountered: