I have a tidytable that I would like to run complete
on for a given set of columns, but for some reason that I can't figure out, usual methods that turn strings into variable names do not work:
input <- tidytable::tidytable(a = sample(LETTERS, size = 100, replace = TRUE),
b = sample(letters, size = 100, replace = TRUE),
c = runif(n = 100))
expected <- input %>% tidytable::complete.(a, b)
columns <- c("a", "b")
attempt1 <- input %>% tidytable::complete.(!!columns) # Error in get_bys(x, y, by) : by.y columns not in y
attempt2 <- input %>% tidytable::complete.(!!!columns) # Error in get_bys(x, y, by) : by.y columns not in y
attempt3 <- input %>% tidytable::complete.(eval(as.name(columns))) # Error in get_bys(x, y, by) : by.y columns not in y
attempt4 <- input %>% tidytable::complete.(eval(quote(columns))) # Error in get_bys(x, y, by) : by.y columns not in y
attempt5 <- input %>% tidytable::complete.(as.name(columns)) # Error in CJ(`as.name(columns)` = .Primitive("quote")(a), unique = TRUE, : 'sorted' is TRUE but element 1 is non-atomic, which can't be sorted; try setting sorted = FALSE
attempt6 <- input %>% tidytable::complete.(vars(tidytable::any_of("a"))) # Error in CJ(`vars(tidytable::any_of(a))` = list(~tidytable::any_of(a)), : 'sorted' is TRUE but element 1 is non-atomic, which can't be sorted; try setting sorted = FALSE
attempt7 <- input %>% tidytable::complete.(as.name(columns, sorted = FALSE)) # Error in as.name(columns, sorted = FALSE) : unused argument (sorted = FALSE)
attempt8 <- input %>% tidytable::complete.(vars(tidytable::any_of("a", sorted = FALSE), sorted = FALSE)) # Error in CJ(`vars(tidytable::any_of(a))` = list(~tidytable::any_of(a)), : 'sorted' is TRUE but element 1 is non-atomic, which can't be sorted; try setting sorted = FALSE