Please find attached my sample dataset @ https://drive.google.com/file/d/1MzAdUEYQ_mf1qivOQtzIoDcdj8KNvJw5/view?usp=sharing.
What I really want to achieve with this is to create a dataframe that first sorts the data based on period on ascending order and within each period that data is sorted again by the descending order of count of case (grouped by period,region,manager,employee)
So far, I have done up to this but it does not give me what I want.
I am planning to plot this values, so that's why I need to sort it on ascending order first and within each of that I want the data to be sorted in descending order.
library(readxl) SampleRADN <- read_excel("C:/Users/xxx/Documents/Exercises/PBIR/SampleRADN.xlsx") df1<-unique(data.frame(SampleRADN)) library(dplyr) df2<-df1%>%count(period,region,manager,employee) df3<-df2[order(df2$period, -df2$n)
Any help is greatly appreciated.