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

Allow expressions in facet formulas #1596

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

Comments

Projects
None yet
4 participants
@dgrtwo
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

@DanRuderman

This comment has been minimized.

Contributor

DanRuderman commented Aug 20, 2016

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

@hadley

This comment has been minimized.

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

This comment has been minimized.

Contributor

DanRuderman commented Aug 26, 2016

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

@thomasp85

This comment has been minimized.

Member

thomasp85 commented Sep 9, 2016

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

@hadley hadley closed this 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.