Summarise Quantile no longer working after update?

The quantile function under summarise is no longer working. I get the following error message:

Error: Column test must be length 1 (a summary value), not 2


mat <- matrix(rnorm(100*4,mean=0,sd=1), 100, 4) 

colnames(mat) <- c("X1","X2","X3","X4")

mat %>% 
  as.data.frame() %>% 
  summarise(test=quantile(X1,c(.25,.5)),
            q=c(.25,.5))

mat %>% 
  as.data.frame() %>% 
  summarise(test=quantile(X1,c(.25,.5)))

I expect the 25th and 50th percentile for X1.

The code you've provided runs for me. Which version of dplyr are you using? You can find out by running packageVersion("dplyr")

Thank you for checking!! I have version ‘0.8.5’ for dplyr. I just realized that I had an outdated version of R (3.6.3) so I updated to 4.0 (and re-installed the tidyverse), but it still isn't working.

Edit: I just uninstalled and reinstalled a lot of things. It was an rlang issue. All working now!

That's the issue right there. Your code is asking summarise() to return multiple values which is a new feature being added in the upcoming 1.0.0 release of dplyr. Read this post for more details.

Thank you! It turns out that I had "upgraded" to the newest version of dplyr, but had an rlang issue that kicked me back down to the "current" version. I'm not sure how it happened, but it's resolved now. Your response was very helpful; thank you!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.