Unused argument in summarise n() R

廉价感情. 提交于 2021-02-10 14:14:58

问题


I am trying to run the following code:

 DF2 %>%

 group_by(doy, yearadded) %>%

 summarise(n_entries= n(doy, yearadded))

Which gives me the error:

Error in n(doy, yearadded) : unused arguments (doy, yearadded)

My yearadded field is a character class and doy is a numeric, is that why it's not working or is there some other reason?


回答1:


The n() doesn't take any arguments. It would be

library(dplyr)
DF2 %>%
 group_by(doy, yearadded) %>%
 summarise(n_entries= n())

Or more compactly

count(DF2, doy, yearadded)


来源:https://stackoverflow.com/questions/55259295/unused-argument-in-summarise-n-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!