Replies: 2 comments 3 replies
-
Workaround 🙃 library(ggplot2)
p <- ggplot(mtcars, aes(hp, mpg)) +
geom_point()
ggtrace::inspect_args(p, Geom$setup_data)
#> Error in .makeTracedFunction(def, tracer, exit, at, print, doEdit): cannot use 'at' argument unless the function body has the form '{ ... }'
assign("setup_data", function(data, params) { data }, envir = Geom)
ggtrace::inspect_args(p, Geom$setup_data)
#> $data
#> x y PANEL group
#> 1 110 21.0 1 -1
#> 2 110 21.0 1 -1
#> 3 93 22.8 1 -1
#> 4 110 21.4 1 -1
#> 5 175 18.7 1 -1
#> 6 105 18.1 1 -1
#> 7 245 14.3 1 -1
#> 8 62 24.4 1 -1
#> 9 95 22.8 1 -1
#> 10 123 19.2 1 -1
#> 11 123 17.8 1 -1
#> 12 180 16.4 1 -1
#> 13 180 17.3 1 -1
#> 14 180 15.2 1 -1
#> 15 205 10.4 1 -1
#> 16 215 10.4 1 -1
#> 17 230 14.7 1 -1
#> 18 66 32.4 1 -1
#> 19 52 30.4 1 -1
#> 20 65 33.9 1 -1
#> 21 97 21.5 1 -1
#> 22 150 15.5 1 -1
#> 23 150 15.2 1 -1
#> 24 245 13.3 1 -1
#> 25 175 19.2 1 -1
#> 26 66 27.3 1 -1
#> 27 91 26.0 1 -1
#> 28 113 30.4 1 -1
#> 29 264 15.8 1 -1
#> 30 175 19.7 1 -1
#> 31 335 15.0 1 -1
#> 32 109 21.4 1 -1
#>
#> $params
#> $params$na.rm
#> [1] FALSE |
Beta Was this translation helpful? Give feedback.
-
From the back of my head, I know there is some obscure S4 generic/method thing that depends on curly braces vs one-liners, but I don't think applies to ggproto objects.
No, just explain in an issue why it would be beneficial first, so there is a record for why this was chosen. Another good side-effect is that RStudio document outlines will list the methods (not sure about Positron). It seems you've already nailed down unit tests by searching for ggproto objects that deviate from expectation, so that'd be good to ensure it doesn't accidentally become defunct. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Have you ever wondered why some one-liner ggproto methods have
{
while others don't?Probably not!
Did you know that a function requires
{
fortrace(at)
to work?Also probably not! 🥲
Question: would this be a too selfish of a thing to PR into ggplot? 😆
(bat signal @teunbrand)
In the spirit of nerding out about the internals, a quick survey of one-liners with and without curly brackets
Beta Was this translation helpful? Give feedback.
All reactions