Skip to content

Commit

Permalink
give lazy_dt a name in pivot_wider test
Browse files Browse the repository at this point in the history
  • Loading branch information
eutwt committed Sep 4, 2021
1 parent 4ccb61a commit 612961f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/step-call-pivot_wider.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Code
show_query(step)
Output
setnames(dcast(`_DT12`, formula = "..." ~ x + y, value.var = c("a",
setnames(dcast(DT, formula = "..." ~ x + y, value.var = c("a",
"b"))[, .(a_X_1, a_Y_2, b_X_1, b_Y_2)], c("a_X_1", "a_Y_2", "b_X_1",
"b_Y_2"), c("X1_a", "Y2_a", "X1_b", "Y2_b"))

Expand Down
13 changes: 8 additions & 5 deletions tests/testthat/test-step-call-pivot_wider.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ test_that("column with `...j` name can be used as `names_from`", {
# column names -------------------------------------------------------------

test_that("names_glue affects output names & auto-converts data.table to lazy_dt", {
df <- data.table(
x = c("X", "Y"),
y = 1:2,
a = 1:2,
b = 1:2
df <- lazy_dt(
data.frame(
x = c("X", "Y"),
y = 1:2,
a = 1:2,
b = 1:2
),
"DT"
)

step <- pivot_wider(df, names_from = x:y, values_from = a:b, names_glue = "{x}{y}_{.value}")
Expand Down

0 comments on commit 612961f

Please sign in to comment.