Aggregate function FR

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Aggregate function FR


I was wondering if it would be possible to add an argument to the aggreagte
function to retain NA by categories?(default can not to in order to avoid
breaking code) Please see below example:

df = iris
df$Species[5] = NA
aggregate(`Petal.Width` ~ Species, df, sum) # does not include NA
aggregate(`Petal.Width` ~ addNA(Species), df, sum) # include NA

data.table and dplyr include NA by default.
Python pandas has an aggreagate function inspired by base R aggregate. An
option has been added to include NA.

Thank you
Best regards

        [[alternative HTML version deleted]]

[hidden email] mailing list