Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Odd insistence on ungroup()
library(dplyr)
library(tidyr)
myDF <- data.frame(A = sample(LETTERS[1:4], 100, replace = TRUE),
B = sample(letters[5:9], 100, replace = TRUE),
C = rnorm(100))
summaryDF <- myDF %>% group_by(A, B) %>% dplyr::summarise(meanC = mean(C))
summaryDF %>% spread(B, meanC) # Error: index out of bounds
summaryDF %>% ungroup() %>% spread(B, meanC) # Works
@petbadger

This comment has been minimized.

Copy link

petbadger commented Aug 7, 2018

The above code actually does work now (at least for me) I find some dplyr nuisances are actually caused by the data being a Tibble. Maybe that was the problem 4 years ago...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.