Skip to content

fix: add [.spec_tbl_df method to drop spec/problems on subsetting (#569) - #631

Closed
LeonidasZhak wants to merge 1 commit into
tidyverse:mainfrom
LeonidasZhak:fix/spec-tbl-df-subset-method
Closed

LeonidasZhak wants to merge 1 commit into
tidyverse:mainfrom
LeonidasZhak:fix/spec-tbl-df-subset-method

Conversation

@LeonidasZhak

Copy link
Copy Markdown

Closes #569.

What

Add a [.spec_tbl_df S3 method to vroom that drops the spec and problems attributes and removes the spec_tbl_df subclass when a data frame is subset with [.

Why

When vroom creates a data frame, it applies the spec_tbl_df class and attaches spec and problems attributes. Without a [.spec_tbl_df method, 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_df method (same pattern as as.data.frame.spec_tbl_df, as_tibble.spec_tbl_df, etc.)
  • R/zzz.R: Register conditionally via s3_register("base::[", "spec_tbl_df") when readr is not loaded
  • tests/testthat/test-vroom.R: Add test verifying that subsetting drops class and attributes

Validation

  • devtools::test(filter = "vroom$"): 354 pass, 0 fail
  • devtools::test(): 1164 pass, 5 pre-existing failures (locale encoding in test-path.R), 0 new failures
  • Verified method works both with and without readr loaded

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
@LeonidasZhak

Copy link
Copy Markdown
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.

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.

Why does vroom not implement [.spec_tbl_df?

1 participant