Skip to content

Don't strip classes in Geom$use_defaults() #5657

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

Merged
merged 3 commits into from
Jan 23, 2024

Conversation

teunbrand
Copy link
Collaborator

This PR to the RC aims to fix #5656.

Briefly, using base::`<-.data.frame` in Geom$use_defaults() causes classes to be stripped on the RHS of the assignment.
This PR uses vec_cbind() to do the same job without stripping classes.
I encountered some reordered rownames during a test, but as these are not important in ggplot2, I'm not concerned.

@teunbrand teunbrand added this to the ggplot2 3.5.0 milestone Jan 22, 2024
@teunbrand teunbrand changed the base branch from main to rc/3.5.0 January 22, 2024 12:47
@teunbrand teunbrand requested a review from thomasp85 January 22, 2024 12:51
@thomasp85
Copy link
Member

how come row names order is affected at all? The code change doesn't do any reordering?

@teunbrand
Copy link
Collaborator Author

I think in some circumstances vec_cbind() just resets rownames to their defaults.

df <- data.frame(x = 1:2, y = 1:2)
rownames(df) <- 3:2
rownames(df)
#> [1] "3" "2"
rownames(vctrs::vec_cbind(df, !!!list(i = 3)))
#> [1] "1" "2"

Created on 2024-01-22 with reprex v2.1.0

@thomasp85
Copy link
Member

gotcha

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

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

LGTM

@teunbrand teunbrand merged commit 7a4af1e into tidyverse:rc/3.5.0 Jan 23, 2024
@teunbrand teunbrand deleted the AsIs_params branch January 23, 2024 07:47
@teunbrand teunbrand mentioned this pull request Feb 7, 2024
thomasp85 pushed a commit that referenced this pull request Feb 23, 2024
* Use `vec_cbind()` instead of data.frame assignment

* ignore rownames in test

* Add test for AsIs class
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.

Support for using I() to use NPC corodinates seems incomplete
2 participants