Skip to content
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

new direction qstat and qlayer #5

Open
EvaMaeRey opened this issue Sep 23, 2024 · 1 comment
Open

new direction qstat and qlayer #5

EvaMaeRey opened this issue Sep 23, 2024 · 1 comment
Assignees

Comments

@EvaMaeRey
Copy link
Owner

EvaMaeRey commented Sep 23, 2024

Work stopped for a while on this project because of the following approach which seemed really concise and in-script appropriate:

StatNew <- ggproto("StatNew", Stat, compute_group = my_compute()

p +
geom_polygon(stat = StatNew)

and wrapping up for more user facing...

geom_new <- function(...){ geom_polygon(StatNew, ...) }

And, the way I was headed seemed hard to keep track of and reason about.

But recent geom_manual work (in ggplot2 tidyverse/ggplot2#6103) has me taking another look at that level of concision, but by piggybacking on the geom_polygon(stat = StatNew ) approach.

Basically, statexpress would provide two things. 1. qstat and 2. qlayer (which are pretty concise themselves actually).

qstat <- function(compute_group, ...){ggproto("StatTemp", Stat, compute_group = compute_group, ...) }

qlayer is just a cross between geom_point and stat_identity, but making both the geom and stat available, and will look a lot like the default boilerplate that you might copy and paste from your last user-facing layer function!

So you can do

p +
geom_polygon(stat = qstat(my_compute))

So you don't need a step just dedicated to naming a stat.

But you have access to default aes, dropped aes, required aes, etc, and compute_panel...

qlayer is nice for cases when you need to use a geom that doesn't have a convenient user-acess way to change the stat:

p +
qlayer(geom = GeomVline, stat = qstat(my_compute)

or also modified Geoms...

p +
qlayer(geom = GeomNewPoint, Stat = qstat(my_compute))

@EvaMaeRey EvaMaeRey self-assigned this Sep 23, 2024
@EvaMaeRey
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant