Assumendo che abbia il seguente codice. Nell'ultimo passaggio, dove cerco di organizzarlo, il codice non funziona e il data frame continua ad essere disposto in ordine crescente entro il cyl
.arrangiare() non funziona sul frame di dati raggruppati
library(dplyr)
# create a grouped data frame
df <- group_by(mtcars,cyl)
# rank car from best mpg to worst for every cyl
df <- mutate(df,rank = row_number(mpg))
# top 3 best mpg for each cyl
df <- filter(df,rank <= 3)
# arrange by the number of cyl
df <- arrange(df,desc(cyl), rank)
Qualche idea sul perché questo sta accadendo?
post simili http://stackoverflow.com/questions/26555297/dplyr-arrange-a-grouped-df-by-group-variable-not-working – hshihab