Skip to content

Hotfix: replace datawizard::data_tabulate() to avoid r-devel NA row name error in report_participants()#603

Merged
rempsyc merged 3 commits intomainfrom
copilot/hotfix-cran-failures
May 4, 2026
Merged

Hotfix: replace datawizard::data_tabulate() to avoid r-devel NA row name error in report_participants()#603
rempsyc merged 3 commits intomainfrom
copilot/hotfix-cran-failures

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 4, 2026

r-devel change r89982 (2026-04-30) makes as.data.frame.*() error when row names contain NA. datawizard::data_tabulate() internally constructs a table() with useNA = "always", producing <NA> as a level; converting that table to a data frame now aborts on r-devel:

Error in as.data.frame.integer(x[[i]], optional = TRUE) :
  row names contain missing values
Calls: report_participants ... data_tabulate -> data.frame -> as.data.frame.integer

Changes

  • R/report_participants.R: In both the text_country and text_race blocks of .report_participants(), replace datawizard::data_tabulate() + as.data.frame() with a direct table() call (default exclude = NA) and inline percentage computation. NAs are already replaced with "missing" before the table is built, so output is identical:
# Before
frequency_table <- as.data.frame(
  datawizard::data_tabulate(data[[country]]),
  stringsAsFactors = FALSE
)[c(2, 4)]
names(frequency_table)[2] <- "Percent"
frequency_table <- frequency_table[-which(is.na(frequency_table$Value)), ]

# After
freq_tbl <- table(data[[country]])
frequency_table <- data.frame(
  Value = names(freq_tbl),
  Percent = as.numeric(freq_tbl) / nrow(data) * 100,
  stringsAsFactors = FALSE
)

… avoid NA row names in r-devel

Agent-Logs-Url: https://github.com/easystats/report/sessions/aadc7586-e780-4972-8f93-af5a77524513

Co-authored-by: rempsyc <13123390+rempsyc@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CRAN failures due to row names containing missing values Hotfix: replace datawizard::data_tabulate() to avoid r-devel NA row name error in report_participants() May 4, 2026
Copilot finished work on behalf of rempsyc May 4, 2026 13:52
Copilot AI requested a review from rempsyc May 4, 2026 13:52
@rempsyc
Copy link
Copy Markdown
Member

rempsyc commented May 4, 2026

@etiennebacher just alerting you that the CRAN failures in report seem related to datawizard::data_tabulate() creating NA rows which now fails on R-devel. Have you had similar reports on your side?

@rempsyc rempsyc marked this pull request as ready for review May 4, 2026 16:00
Copilot AI review requested due to automatic review settings May 4, 2026 16:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hotfixes report_participants() to avoid an r-devel failure triggered by datawizard::data_tabulate() producing <NA> row names that now break as.data.frame(). It keeps the participant-summary output logic the same while switching the country/race tabulation to a simpler base-R path and updates package metadata/docs for the release.

Changes:

  • Replaced datawizard::data_tabulate() with direct table()-based frequency/percentage calculation in the country and race branches of .report_participants().
  • Bumped the package version and added a NEWS entry for the r-devel compatibility fix.
  • Regenerated/updated related documentation and metadata files.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
R/report.character.R Formatting-only change to multiline as.report_parameters() call.
R/report_participants.R Core hotfix: rewrites country/race frequency table creation to avoid the r-devel NA row-name failure.
NEWS.md Documents the report_participants() hotfix.
man/report.compare.loo.Rd Regenerated/help-link update for report.compare.loo.
man/report-package.Rd Regenerated package author list.
man/reexports.Rd Regenerated reexports documentation links.
DESCRIPTION Version bump and regenerated roxygen metadata.

@rempsyc rempsyc merged commit b9fd1ff into main May 4, 2026
31 of 32 checks passed
@rempsyc rempsyc deleted the copilot/hotfix-cran-failures branch May 4, 2026 16:09
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.

[Copilot]: Hotfix CRAN failures (row names contain missing values)

3 participants