-
Notifications
You must be signed in to change notification settings - Fork 1k
Added shallow search for data.table in tables() #7580
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
Changes from 30 commits
803f763
b9fdca8
107a65b
ca8701e
174b0ea
03e58c9
3ba7c1b
1e1fd11
1952290
40a188d
0f70dc9
2f19256
afd197a
b591887
866820a
2880f1e
c65ff92
9c0e83d
3d76ab1
9e693b8
4e3f26d
8d0f470
eca52e9
23278d4
55cd69f
21a2471
8573307
1112968
d4c668e
6808d22
5461066
72a01f9
e2ae2ce
d2c771c
0e592f4
cf0b3a1
9cedd42
5a5a364
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21514,11 +21514,46 @@ test(2364.2, levels(x$a), levels(y$a)) | |
| rm(x, y) | ||
|
|
||
| # test for data.frame reshape for melt | ||
| df_melt = data.frame(a = 1:2, b = 3:4) | ||
| dt_melt = data.table(a = 1:2, b = 3:4) | ||
| df_melt = data.frame(a=1:2, b=3:4) | ||
| dt_melt = data.table(a=1:2, b=3:4) | ||
| test(2365.1, melt(df_melt, id.vars=1:2), melt(dt_melt, id.vars=1:2)) | ||
|
|
||
| # test for data.frame reshape for dcast | ||
|
MichaelChirico marked this conversation as resolved.
Outdated
|
||
| df_dcast = data.frame(a = c("x", "y"), b = 1:2, v = 3:4, stringsAsFactors = FALSE) | ||
| dt_dcast = data.table(a = c("x", "y"), b = 1:2, v = 3:4) | ||
| test(2365.2, dcast(df_dcast, a ~ b, value.var = "v"), dcast(dt_dcast, a ~ b, value.var = "v")) | ||
| df_dcast = data.frame(a=c("x", "y"), b=1:2, v=3:4, stringsAsFactors=FALSE) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: data.table style is to omit spaces before and after named arguments: |
||
| dt_dcast = data.table(a=c("x", "y"), b=1:2, v=3:4) | ||
|
MichaelChirico marked this conversation as resolved.
Outdated
|
||
| test(2365.2, dcast(df_dcast, a~b, value.var="v"), dcast(dt_dcast, a~b, value.var="v")) | ||
|
|
||
| #2606 tables() depth=1 finds nested data.tables in lists | ||
| # creating env so that the names are within it | ||
| xenv = new.env() | ||
| xenv$DT = data.table(a=1L) | ||
| xenv$L = list(data.table(a=1, b=4:6), data.table(a=2, b=7:10)) | ||
| xenv$LL = list(list(data.table(a=1L, b=4:6))) | ||
| xenv$M = list(b=data.table(a=1, b=4:6), a=1:5) | ||
| xenv$N = list(a=1:5) | ||
| test(2366.1, | ||
| tables(env=xenv, depth=1L, index=TRUE)[, .(NAME, NROW, NCOL, INDICES, KEY)], | ||
|
MichaelChirico marked this conversation as resolved.
|
||
| data.table( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't use tryCatch like this in our suite; you can use the |
||
| NAME = c("DT", "L[[1]]", "L[[2]]", "M$b"), | ||
| NROW = c(1L, 3L, 4L, 3L), | ||
| NCOL = c(1L, 2L, 2L, 2L), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment is maybe in the wrong place? |
||
| INDICES = list(NULL, NULL, NULL, NULL), | ||
| KEY = list(NULL, NULL, NULL, NULL) | ||
| )) | ||
| setindex(xenv$M$b, b) | ||
| test(2366.2, | ||
| tables(env=xenv, depth=1L, index=TRUE)[, .(INDICES, KEY)], | ||
| data.table(INDICES = list(NULL, NULL, NULL, "b"), KEY = list(NULL, NULL, NULL, NULL))) | ||
| setkey(xenv$M$b, a) | ||
| test(2366.3, | ||
| tables(env=xenv, depth=1L, index=TRUE)[, .(INDICES, KEY)], | ||
| data.table(INDICES = list(NULL, NULL, NULL, "b"), KEY = list(NULL, NULL, NULL, "a"))) | ||
| # test for depth>1L | ||
| test(2366.4, tables(env=xenv, depth=2L), error="depth>1L is not implemented yet") | ||
| rm(xenv) | ||
|
|
||
| # no data.table test | ||
| xenv_empty = new.env() | ||
| test(2366.5, tables(env=xenv_empty, depth=1L), invisible(data.table(NULL))) | ||
| test(2366.6, tables(env=xenv_empty), invisible(data.table(NULL))) | ||
| rm(xenv_empty) | ||
Uh oh!
There was an error while loading. Please reload this page.