Closed Darxor closed 2 years ago
This looks great @Darxor! Thanks for the help 😄
I have a few small changes requested above.
Can you also do me a favor and add this test to the bottom of test-pivot_wider.R
?
test_that("correctly labels columns when `names_glue` is used, #579", {
# length(values_from) == 1
df1 <- tidytable(
lettr = c("b", "a", "c"),
v1 = c("b", "a", "c")
)
result1 <- pivot_wider.(
df1,
names_from = lettr,
values_from = v1,
names_glue = "{.value}_{lettr}"
)
expect_named(result1, c("v1_a", "v1_b", "v1_c"))
expect_equal(unname(unlist(result1)), c("a", "b", "c"))
# length(values_from) > 1
df2 <- tidytable(
lettr = c("b", "a", "c"),
v1 = c("b", "a", "c"),
v2 = c("b", "a", "c")
)
result2 <- pivot_wider.(
df2,
names_from = lettr,
values_from = c(v1, v2),
names_glue = "{.value}_{lettr}"
)
expect_named(result2, c("v1_a", "v1_b", "v1_c", "v2_a", "v2_b", "v2_c"))
expect_equal(unname(unlist(result2)), c("a", "b", "c", "a", "b", "c"))
})
Thanks for your feedback @markfairbanks! All done now, happy to help :)
Thanks again! Would you like to be added to the contributor list? Basically your name would show up here under the authors as a contributor.
Absolutely! I would be quite honored to see my name there! :)
Is "Alexander Sevostianov" correct for first and last name?
Yup, it is
Fixes #579
Variable
glue_vars
now has names, that mimicdata.table::dcast
's output column names These names are used to map values onto new column names afterdcast
callTests should also probably be added to cover this edge case.