Open kevinushey opened 1 year ago
This would be easier if ggplot2 would provide some kind of machine readable list of function
-> supported aes
, like roxygen2 does with its tags
https://github.com/r-lib/roxygen2/blob/main/inst/roxygen2-tags.yml
Pardon for just barging into this issue. For building such a list, you can query the accepted arguments in aes()
with the following function:
get_aes <- function(layer) {
union(layer$geom$aesthetics(), layer$stat$aesthetics())
}
get_aes(ggplot2::geom_point())
#> [1] "x" "y" "shape" "colour" "size" "fill" "alpha" "stroke"
#> [9] "group"
get_aes(ggplot2::geom_polygon())
#> [1] "x" "y" "colour" "fill" "linewidth" "linetype"
#> [7] "alpha" "subgroup" "group"
Created on 2024-07-12 with reprex v2.1.1
I'm not sure how well a static list would interface with ggplot2's extension system and it probably wouldn't catch any changes made using update_geom/stat_params()
(but the latter is more of a technicality one could safely ignore in 99.9% of cases).
I imagine we'll end up with a mix of static and dynamic annotations to instruct Ark about injected symbols.
I ended up doing a bunch of crazy nonsense in RStudio to make this work:
It'd be much nicer to have a straightforward solution that ark can use.
I think an example of this code would be something like:
where the valid autocompletion results for that
aes()
call would be inferred based on the aesthetics accepted bygeom_point()
.