same answer as the second part of the one by @r2evans, but for a more recent version of dplyr (1.1.4), without the superseded functions (summarize_at() and one_of)
note that this doesn't throw a warning regarding columns that do not exist in the dataframe, due to the use of any_of()
iris %>%
select(-Sepal.Length) %>%
group_by(Species) %>%
summarize(across(.cols=any_of(c("Sepal.Width",
"Sepal.Length")),
.fns=mean))
# A tibble: 3 × 2
# Species Sepal.Width
# <fct> <dbl>
# 1 setosa 3.43
# 2 versicolor 2.77
# 3 virginica 2.97