dplyr group_by and mutate, how to access the data frame?

前端 未结 2 1307
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-14 04:13

When using dplyr\'s \"group_by\" and \"mutate\", if I understand correctly, the data frame is split in different sub-dataframes according to the group_by argument. For examp

2条回答
  •  暖寄归人
    2020-12-14 05:15

    We can use within do

    data %>%
        group_by(let ) %>% 
        do(mutate(., mean.by.letter = mean(.$x)))
    

提交回复
热议问题