fix: add [.spec_tbl_df method to drop spec/problems on subsetting (#569) - #631
Closed
LeonidasZhak wants to merge 1 commit into
Closed
LeonidasZhak wants to merge 1 commit into
LeonidasZhak wants to merge 1 commit into
Conversation
When a vroom-created data frame with class 'spec_tbl_df' is subset with [, the 'spec' and 'problems' attributes and 'spec_tbl_df' class are now dropped, consistent with readr's behavior. This prevents stale spec/problems metadata from persisting after subsetting, which could confuse users and tools that inspect these attributes. - R/utils.R: Add [.spec_tbl_df method - R/zzz.R: Register conditionally when readr is not loaded - tests/testthat/test-vroom.R: Add test for subsetting behavior
Author
|
I am withdrawing this PR as part of a broader cleanup of an oversized automated contribution batch. I am sorry for the review noise and the pressure this may have put on maintainers. Going forward I will keep contributions to this project much more limited and higher-signal, ideally only one or two focused PRs at a time. Thank you for maintaining the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #569.
What
Add a
[.spec_tbl_dfS3 method to vroom that drops thespecandproblemsattributes and removes thespec_tbl_dfsubclass when a data frame is subset with[.Why
When vroom creates a data frame, it applies the
spec_tbl_dfclass and attachesspecandproblemsattributes. Without a[.spec_tbl_dfmethod, these attributes persist after subsetting, which can confuse users and tools that inspect them. readr already has this method; vroom should too.Changes
R/utils.R: Add[.spec_tbl_dfmethod (same pattern asas.data.frame.spec_tbl_df,as_tibble.spec_tbl_df, etc.)R/zzz.R: Register conditionally vias3_register("base::[", "spec_tbl_df")when readr is not loadedtests/testthat/test-vroom.R: Add test verifying that subsetting drops class and attributesValidation
devtools::test(filter = "vroom$"): 354 pass, 0 faildevtools::test(): 1164 pass, 5 pre-existing failures (locale encoding in test-path.R), 0 new failures