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"
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:
But I get the error message: