Skip to content

Instantly share code, notes, and snippets.

@jnolis
Created June 30, 2021 04:11
Show Gist options
  • Save jnolis/767e8ee4bfbbca04eb26fd4029c16026 to your computer and use it in GitHub Desktop.
Save jnolis/767e8ee4bfbbca04eb26fd4029c16026 to your computer and use it in GitHub Desktop.
group_split + furrr::map_dfr()
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