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

Length > 1 warning on from is.ggtrace_placeholder() #94

Closed
yjunechoe opened this issue Dec 6, 2022 · 0 comments
Closed

Length > 1 warning on from is.ggtrace_placeholder() #94

yjunechoe opened this issue Dec 6, 2022 · 0 comments
Labels

Comments

@yjunechoe
Copy link
Owner

Reprex

library(ggplot2)
ggplot(mtcars, aes(mpg, hp)) +
  geom_point(aes(color = as.factor(cyl)))

library(ggtrace)
l <- ggtrace_inspect_return(last_plot(), ggplot2:::guide_gengrob.legend, cond = 1)
#> Warning in .is_traced(what, where) || is.ggtrace_placeholder(._return):
#> 'length(x) = 4 > 1' in coercion to 'logical(1)'

l
#> TableGrob (7 x 6) "layout": 11 grobs
#>     z     cells       name                              grob
#> 1   1 (1-7,1-6) background rect[legend.background..rect.120]
#> 2   2 (2-2,2-5)      title             gTree[GRID.gTree.121]
#> 3   3 (4-4,2-2) key-3-1-bg        rect[legend.key..rect.111]
#> 4   4 (4-4,2-2)  key-3-1-1           points[GRID.points.112]
#> 5   5 (5-5,2-2) key-4-1-bg        rect[legend.key..rect.114]
#> 6   6 (5-5,2-2)  key-4-1-1           points[GRID.points.115]
#> 7   7 (6-6,2-2) key-5-1-bg        rect[legend.key..rect.117]
#> 8   8 (6-6,2-2)  key-5-1-1           points[GRID.points.118]
#> 9   9 (4-4,4-4)  label-3-3             gTree[GRID.gTree.122]
#> 10 10 (5-5,4-4)  label-4-3             gTree[GRID.gTree.123]
#> 11 11 (6-6,4-4)  label-5-3             gTree[GRID.gTree.124]
ggtrace::ggdraw_silent(l)

Created on 2022-12-06 with reprex v2.0.2

Problem

Ugh I'm dumb:

ggtrace:::is.ggtrace_placeholder
#> function (x) 
#> class(x) == "ggtrace_placeholder"
#> <bytecode: 0x000001a9977850e0>
#> <environment: namespace:ggtrace>
ggtrace:::is.ggtrace_placeholder(l)
#> [1] FALSE FALSE FALSE FALSE

Should I use is()? That requires import from {methods} but it's stdlib so should be ok...

is(l, "ggtrace_placeholder")
#> [1] FALSE
is(ggtrace:::.ggtrace_placeholder, "ggtrace_placeholder")
#> [1] TRUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant