Skip to content

Consider sum() interface #1

Description

@hadley

Unfortunately I can no longer find the bluesky post that pointed this out, but:

(ggplot(mpg, aes(x="displ", y="hwy", colour="class"))
 + geom_point()
 + geom_smooth(method="lm")
 + facet_wrap("drv")
 + theme_minimal()
 + labs(title="Engine Displacement vs Highway MPG"))

Is not much better than

sum(
  ggplot(mpg, aes(x="displ", y="hwy", colour="class")),
  geom_point(),
  geom_smooth(method="lm"),
  facet_wrap("drv"),
  theme_minimal(),
  labs(title="Engine Displacement vs Highway MPG"),
)

So it might be worth considering if overloading + is even worth it.

You can see a bit of historical context at https://github.com/hadley/ggplot1 — ggplot2 only used the plus because I couldn't see a better way to do function composition.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions