Package tidyverse can not be used together with plyr?

I have a project need to use min_rank from tidyvers, but when I loaded plyr (use it for data aggregation), ranking function doesn't work. Is there any way to make tidyverse able to work together with plyr? thank you.


To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

Here is a example:


# it works well here
mydata1<- mydata %>% group_by(cyl) %>% mutate(Rank=min_rank(desc(mpg))) 
mydata1<- mydata1[order(mydata1$cyl,mydata1$Rank),]

# after loading plyr, doesn't work, ranking is not grouped.
mydata2<- mydata %>% group_by(cyl) %>% mutate(Rank=min_rank(desc(mpg))) 
mydata2<- mydata2[order(mydata2$cyl,mydata2$Rank),]

# To make it work again, have to re-install tidyvers.

By loading plyr later you are masking some function names

The following objects are masked from ‘package:dplyr’:

arrange, count, desc, failwith, id, mutate, rename, summarise, summarize

I don't see a reason for using plyr over dplyr but you can solve this problem by being specific about the source package for each masked function e.g.

mtcars %>% 
    group_by(cyl) %>%
    dplyr::mutate(Rank=min_rank(dplyr::desc(mpg))) %>% 
    dplyr::arrange(cyl, Rank)
1 Like

Great! it works well. Thank you so much!

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