New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete/expand with additional combinations #121

Closed
danielsjf opened this Issue Oct 9, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@danielsjf

danielsjf commented Oct 9, 2015

Is it possible to implement a way to include permutations using more than just the options provided in the data frame?

Now it works like this:

> data.frame(a=c(1,2),b=c(3,4)) %>%
    expand(a,b)
Source: local data frame [4 x 2]
      a     b
  (dbl) (dbl)
1     1     3
2     1     4
3     2     3
4     2     4

But it would be nice to have something like this:

> data.frame(a=c(1,2),b=c(3,4)) %>%
    expand(a,b=c(3:5))
Source: local data frame [6 x 2]
      a     b
  (dbl) (dbl)
1     1     3
2     1     4
3     1     5
4     2     3
5     2     4
6     2     5

The exact same problem holds for complete.

@hadley

This comment has been minimized.

Member

hadley commented Dec 30, 2015

Hmmm, I'm not sure it's possible to make this work in expand() because it currently (for good reason), has select-like semantics, and there's no reliable way to tell the difference between these two calls:

df %>% expand(b = a)
a <- 1:4
df %>% expand(b = a)

I think that suggests we need another variant on expand(). I suspect we also need expand_grid() which doesn't use data at all (I still find myself reaching for expand.grid() when I want to create completely new datasets)

@hadley hadley closed this in cc0b0e0 Dec 31, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment