batchApply | R Documentation |
Apply a function to batches of data in an Andromeda table
batchApply(tbl, fun, ..., batchSize = 1e+05, progressBar = FALSE, safe = FALSE)
tbl |
An |
fun |
A function where the first argument is a data frame. |
... |
Additional parameters passed to fun. |
batchSize |
Number of rows to fetch at a time. |
progressBar |
Show a progress bar? |
safe |
Create a copy of tbl first? Allows writing to the same Andromeda as being read from. |
This function is similar to the lapply()
function, in that it applies a function to sets of
data. In this case, the data is batches of data from an Andromeda
table. Each batch will be
presented to the function as a data frame.
Invisibly returns a list of objects, where each object is the output of the user-supplied function applied to a batch
groupApply()
andr <- andromeda(cars = cars)
fun <- function(x) {
return(nrow(x))
}
result <- batchApply(andr$cars, fun, batchSize = 25)
result
# [[1]]
# [1] 25
#
# [[2]]
# [1] 25
close(andr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.