aggregate function works fine
aggregate(weight ~ feed, data = chickwts, mean)
feed weight
1 casein 323.5833
2 horsebean 160.2000
3 linseed 218.7500
4 meatmeal 276.9091
5 soybean 246.4286
6 sunflower 328.9167
But after loading library(memisc) in R 2.14.1, the same code produces the following error
Error in `[.default`(xj, i) : invalid subscript type 'closure'
What is the problem and how to solve this? Thanks in advance for your help.
This package redefines the aggregate method.
There is often a warning in those cases, but since aggregate.formula is a hidden method, there is no warning.
You can explicitely use the initial aggregate function by specifying its namespace
(three colons are needed because it is a hidden method).
stats:::aggregate.formula(weight ~ feed, data = chickwts, mean)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With