Skip to content
Prev 38952 / 63424 Next

aggregate(as.formula("some formula"), data, function) error when called from in a function

On Wed, Jan 26, 2011 at 2:04 PM, Paul Bailey <pdbailey at umd.edu> wrote:
The problem is that the aggregate statement:

agg2 <- aggregate(fo, data = dat, sum)

is using non-standard evaluation and is literally looking at fo rather
than fo's value.  This may be a bug in aggregate.formula but at any
rate you could try replacing that statement with the following to
force fo to be evaluated:

agg2 <- do.call(aggregate, list(fo, data = dat, FUN = sum))