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

Reshape on multiple columns fails when args are passed as named lists #2949

Closed
sunbee opened this issue Jun 21, 2018 · 2 comments · Fixed by #3384
Closed

Reshape on multiple columns fails when args are passed as named lists #2949

sunbee opened this issue Jun 21, 2018 · 2 comments · Fixed by #3384
Labels
Milestone

Comments

@sunbee
Copy link

sunbee commented Jun 21, 2018

Is it possible to reshape on multiple columns by passing a list of column names (value.var) along with a list of aggregation functions (fun.aggregate). This works well when those lists are explicitly passed to the function arguments. It appears to result in an error condition if the lists are passed as variables.

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)
funs = list(sum, mean)
vars = list("d1", "d2")
dcast(dt, x + y ~ z, fun=funs, value.var=vars)

R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] testthat_2.0.0 data.table_1.11.4

loaded via a namespace (and not attached):
[1] compiler_3.5.0 magrittr_1.5 R6_2.2.2 tools_3.5.0 rlang_0.2.1

@MarkusBonsch
Copy link
Contributor

Very strange. I figured it appears if fun is a predefined list, not so much on value.var.
Unfortunately rather low priority at the moment since there are bigger issues.

@arunsrinivasan
Copy link
Member

Also acknowledge #1974 when done.

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

Successfully merging a pull request may close this issue.

4 participants