程序设计希望能将数据按照sp分组,通过自己定义的函数计算不同sp的relativeBA和relativeN,但是并没有成功达到预期,报错如下:
- > groups.importance_by_sp=summarise(sp_groups,BA_relative=relativeBA(),N_relative=relativeN())
- `summarise()` has grouped output by 'sp'. You can override using the `.groups` argument.
- Warning message:
- Returning more (or less) than 1 row per `summarise()` group was deprecated in dplyr 1.1.0.
- ℹ Please use `reframe()` instead.
- ℹ When switching from `summarise()` to `reframe()`, remember that `reframe()` always returns an ungrouped data frame and adjust
- accordingly.
- Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.
- > groups.importance_by_sp=reframe(sp_groups,BA_relative=relativeBA(),N_relative=relativeN())
- > groups.importance_by_sp
- # A tibble: 21,112 × 3
- sp BA_relative N_relative
- <chr> <dbl> <dbl>
- 1 乌桕 0.00000167 1
- 2 乌桕 0.00000211 1
- 3 乌桕 0.00000329 1
- 4 乌桕 0.00000437 1
- 5 乌桕 0.00000147 1
复制代码提示我改用reframe函数,但修改后,根本没有分组计算,而是对原数据每一行分开进行了处理。请问是不是我的定义函数哪里需要修改呢?求大神帮助~谢谢!