Skip to content

fix: detect NA count by length instead of name in tidy.summaryDefault#1277

Open
LeonidasZhak wants to merge 1 commit into
tidymodels:mainfrom
LeonidasZhak:fix/summaryDefault-r-devel
Open

fix: detect NA count by length instead of name in tidy.summaryDefault#1277
LeonidasZhak wants to merge 1 commit into
tidymodels:mainfrom
LeonidasZhak:fix/summaryDefault-r-devel

Conversation

@LeonidasZhak

Copy link
Copy Markdown

Problem

tidy.summaryDefault() breaks in R-devel because it relies on the name "NA's" in summary() output to detect the NA count row. R-devel (PR#18948) changes this label, causing a size mismatch error:

Error in `purrr::set_names()`:
  ! The size of `nm` (6) must be compatible with the size of `x` (7).

Fixes #1259.

Fix

Instead of checking for specific name strings ("NA's", "NAs"), detect the NA count column by comparing ncol(ret) to the expected base column count (6). This is robust to any future label changes.

Changes

  • R/deprecated-0-7-0.R: Replace name-based check with length-based check

Validation

  • Tested with current R (4.5.2) where "NA's" is the label: works correctly
  • Simulated R-devel label change: old code fails, new code succeeds
  • Both with-NA and without-NA cases produce correct output

R-devel (PR#18948) changes the 'NA.s' label in summary() output.
The old code checked for specific name strings ('NA.s', 'NAs'),
which breaks when the label changes. Instead, detect the NA count
column by comparing ncol(ret) to the expected base column count.

Fixes tidymodels#1259
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.

retire tidy.summaryDefault and glance.summaryDefault

1 participant