Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
smidelius opened this issue Mar 19, 2017 · 2 comments

Comments

@smidelius
Copy link

@smidelius smidelius commented Mar 19, 2017

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"

@franknarf1
Copy link
Contributor

@franknarf1 franknarf1 commented Mar 19, 2017

Related to this SO question and issue #1369.

@arunsrinivasan
Copy link
Member

@arunsrinivasan arunsrinivasan commented Mar 30, 2017

dup of #1369

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants