如何分组两次?

I'd like to know how to group twice in a data set. I must answer the following question: "For each state, which municipalities have the lowest and the highest infections and death rates?". This question is part of a homework (https://github.com/umbertomig/intro-prob-stat-FGV/blob/master/assignments/hw6.Rmd) and I don't know how to do it. I've tried to use top_n, but I am not sure if this is the best way.

我想生成一个数据集,其中每个州有四个市(两个州的冠状病毒感染和死亡率最高,而两个则最小)。到目前为止,这是做的:

library(tidyverse)

brazilcorona <- read.csv("https://raw.githubusercontent.com/umbertomig/intro-prob-stat-FGV/master/data sets/brazilcorona.csv")

brazilcorona_hl_rates <- select(brazilcorona, (estado:emAcompanhamentoNovos)) %>%
  filter(data >= "2020-05-15") %>%
  subset(!(coduf == 76)) %>%
  mutate(av_inf = (casosAcumulado/populacaoTCU2019)*100000,
         av_dth = (obitosAcumulado/populacaoTCU2019)*100000)

brazilcorona_hilow_rates <- brazilcorona_hl_rates %>%
  group_by(estado) %>%
  summarize(top_dth = top_n(1, av_dth))