问题
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