I can’t seem to figure out how to use expand to get all combinations of values for all variables in df without specifying each var name explicitly? It’s easy with expand.grid. tibble(x=1:3, y=1:3) %>% expand.grid(). Can I tell expand() to use all vars?
@hadley asked if I would file an issue so he could think about it some more.
I suppose the Tweet is self-explanatory, I want to be able to expand a data frame for all possible combinations of values for every variable, without having to specify variable names explicitly.
This works:
tibble(x = 1:3, y = 1:3) %>% expand.grid()
This doesn't:
tibble(x = 1:3, y = 1:3) %>% expand()
Of course, in the two variable setting, explicitly typing tibble(x = 1:3, y = 1:3) %>% expand(x, y) is not a problem, but it doesn't scale well.
Something like this might be a possible solution:
tibble(x = 1:3, y = 1:3) %>% expand(vars(everything()))
The text was updated successfully, but these errors were encountered:
Hi,
I posted the following question on Twitter:
@hadley asked if I would file an issue so he could think about it some more.
I suppose the Tweet is self-explanatory, I want to be able to expand a data frame for all possible combinations of values for every variable, without having to specify variable names explicitly.
This works:
This doesn't:
Of course, in the two variable setting, explicitly typing
tibble(x = 1:3, y = 1:3) %>% expand(x, y)is not a problem, but it doesn't scale well.Something like this might be a possible solution:
The text was updated successfully, but these errors were encountered: