Description Usage Arguments Value Examples
In the vector method, attempts to apply fun to inp that result in an error will return NAs for that batch.
However, in the dataframe method, these will be returned as NULL
s and not applied to the output.
1 2 |
inp |
(vector, dataframe) A vector or dataframe of inputs. |
fun |
(function) A function to apply to the input. This is what is returned if |
fun_2 |
(function) Optional secondary function to apply to the result of |
n_batches |
(integer) Number of batches to split inp into. |
grow_full_output |
(boolean) Should the result of each batch be combined with the ones before it and the whole result returned at the end? |
verbose |
(boolean) Should progress be messaged? |
... |
Further arguments. |
A dataframe or vector, depending on the type of inp.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | add_one <- function(tbl) {
tbl %>% purrr::map_dbl(~.x + 1)
}
batch_it(mtcars$mpg, fun = add_one, n_batches = 3)
print_it <- function(tbl) {
tbl %>% purrr::map_dbl(~ print(.x))
}
# Print the result of each batch, but don't return the full output at the end
batch_it(mtcars$mpg, fun = add_one, fun_2 = print_it, n_batches = 8, grow_full_output = FALSE)
add_one_tbl <- function(tbl) {
tbl %>% purrr::map_dfr(~.x + 1)
}
batch_it(mtcars, add_one_tbl, n_batches = 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.