Is there a way to know if a table was renamed in the process of unnesting? I want to know if there is something where I can intercept any messages that come through with New names:
and give more context about solutions
# min reprex
library(tidyverse)
f <- function() {
tibble(
x = 1:2,
y = 2:1,
z = tibble(x = 1)
) |>
unnest_wider(z, names_repair = "unique")
}
f()
New names:
• `x` -> `x...1`
• `x` -> `x...3`
x...1 y x...3
----- ----- -----
1 2 1
2 1 1
More context:
The message stems from
vctrs::vec_as_names(c("x", "x"), repair = "universal")
I see information about
withCallingHandlers()
but not sure if that is the right route. I thought there was a way for errors/messages to have classes that you can intercept but I can't remember what I read.Something in
testthat::expect_message()
may help. I thought there would be ahas_message()
function out there.There is a lot of tidy evaluation and comparing names before and after might be tricky. I could look for the names with the regex
"\\.+\\d+$"
but not sure that is robust enough since data could have fields with that syntax already.