Skip to content

define multiple aggregation functions outside of dcast and refer to them inside of dcast #2064

@smidelius

Description

@smidelius

I want to define multiple aggregation functions in custom number/order outside of dcast and then pass it to dcast fun parameter.

I try to achieve something like that:


dt <-  data.table(x=sample(5,20,TRUE), y=sample(2,20,TRUE), 
                z=sample(letters[1:2], 20,TRUE), d1 = runif(20), d2=1L)

functions <- list(sum,mean)

dcast(dt, x + y ~ z, fun=functions, value.var="d1") 

But I get the error message:

Error in eval(expr, envir, enclos) : could not find function "functions"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions