Created
October 16, 2014 17:25
-
-
Save dsparks/9a9d80ec168ff5eab45c to your computer and use it in GitHub Desktop.
Odd insistence on ungroup()
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(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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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...