Skip to content

Conversation

yjunechoe
Copy link
Contributor

Fixes #6467 - layer expression shows up correctly on print

p_expr <- parse(text = "
  p <- ggplot() +
    geom_point(size = 5)
")
eval(p_expr)

p$layers[[1]]$constructor
#> geom_point(size = 5)

I don't think I see existing tests for $constructor and this is only a minor display change, but if we were to add a test for the PR it'd be something like:

expect_identical(
  capture.output(p$layers[[1]]$constructor),
  "geom_point(size = 5)"
)

Copy link
Collaborator

@teunbrand teunbrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thanks for the contribution!

@teunbrand teunbrand merged commit 5ad8736 into tidyverse:main May 27, 2025
13 checks passed
@yjunechoe yjunechoe deleted the strip-constructor-srcref branch May 27, 2025 16:51
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

Successfully merging this pull request may close these issues.

layer()$constructor can be misleading

2 participants