dplyr to output class data.frame

前端 未结 2 957
时光说笑
时光说笑 2021-02-07 09:21

I can summarise a data frame with dplyr like this:

mtcars %>%
group_by(cyl) %>%
summarise(mean(mpg))

To convert the output b

2条回答
  •  清歌不尽
    2021-02-07 09:55

    In addition to what G. Grothendieck mentioned above, you can convert it into a new dataframe:

    new_summary <- mtcars %>%
       group_by(cyl) %>%
       summarise(mean(mpg)) %>%
       as.data.frame()
    

提交回复
热议问题