Multiple variables can be used in nesting()
by separating them by commas. For situations where there are MANY variables, it might be easier to use the :
idiom like what it is used in select()
(from dplyr
). I am wondering if this is possible?
For these example data (modified from the complete()
documentation),
library(dplyr, warn.conflicts = FALSE)
df <- tibble(
group = c(1:2, 1),
item_id = c(1:2, 2),
item_name = c("a", "b", "b"),
something = c("c", "d", "d"),
another = c("z", "y", "X"),
value1 = 1:3,
value2 = 4:6
)
This works ...
df %>% complete(group, nesting(item_id, item_name, something, another))
But I would like this to work for contiguous variable names (but it does not)
df %>% complete(group, nesting(item_id:another))
Of course, my use case has more than four variables for nesting()
.
Is there something similar to this that is possible in nesting()
?