Created
June 30, 2021 04:11
-
-
Save jnolis/767e8ee4bfbbca04eb26fd4029c16026 to your computer and use it in GitHub Desktop.
group_split + furrr::map_dfr()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(furrr) | |
library(dplyr) | |
future::plan(future::multisession()) # This is for windows, might want something else for Linux | |
data <- data.frame(letter = sample(letters,num_samples, replace = TRUE), | |
value = runif(num_samples)) | |
data %>% | |
group_by(letter) %>% | |
group_split() %>% | |
furrr::future_map_dfr(function(.x){ | |
tibble(letter = first(.x$letter), value = sum(.x$value)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment