create_chunk_mapper | R Documentation |
A function to make it easier to create functions like filter
create_chunk_mapper(chunk_fn, warning_msg = NULL, as.data.frame = FALSE)
chunk_fn |
The dplyr function to create a mapper for |
warning_msg |
The warning message to display when invoking the mapper |
as.data.frame |
force the input chunk of a data.frame; needed for dtplyr |
filter = create_chunk_mapper(dplyr::filter) #' example: creating a function that keeps only the first and last n row first_and_last <- function(chunk, n, ...) { nr = nrow(chunk) print(nr-n+1:nr) chunk[c(1:n, (nr-n+1):nr), ] } #' create the function for use with disk.frame first_and_last_df = create_chunk_mapper(first_and_last) mtcars.df = as.disk.frame(mtcars) #' the operation is lazy lazy_mtcars.df = mtcars.df %>% first_and_last_df(2) #' bring into R collect(lazy_mtcars.df) #' clean up delete(mtcars.df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.