Skip to content

Allow expressions in facet formulas #1596

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

Closed
dgrtwo opened this issue Mar 24, 2016 · 4 comments
Closed

Allow expressions in facet formulas #1596

dgrtwo opened this issue Mar 24, 2016 · 4 comments
Labels
feature a feature request or enhancement
Milestone

Comments

@dgrtwo
Copy link
Member

dgrtwo commented Mar 24, 2016

I'd like to be able to put expressions in faceted formulae instead of just column names.

For example, I'd like to be able to facet by a "cut" of a column:

ggplot(mtcars, aes(qsec, mpg)) +
  geom_point() +
  facet_wrap(~ cut(wt, c(0, 2, 4, 6)))

rather than needing to do something like:

mtcars$cut <- cut(mtcars$wt, c(0, 2, 4, 6))

ggplot(mtcars, aes(qsec, mpg)) +
  geom_point() +
  facet_wrap(~ cut)
@hadley hadley added this to the v2.2.0 milestone Jul 28, 2016
@hadley hadley added feature a feature request or enhancement ready labels Jul 28, 2016
@DanRuderman
Copy link
Contributor

Great feature. Syntax-wise, how would you handle the overloading of + as both an arithmetic operation and a separator in the formula?

@hadley
Copy link
Member

hadley commented Aug 20, 2016

It would have to be handled the same way as modelling formulas — if you want addition you need to surround in I()

@DanRuderman
Copy link
Contributor

First attempt in #1722. Will be shelved until some infrastructure changes take place.

@thomasp85
Copy link
Member

#1722 has now been ported to the new facet implementation in #1633

@hadley hadley closed this as completed Sep 20, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants