Skip to content

Return columns winsorize() can't handle unchanged - #753

Merged
jmgirard merged 3 commits into
mainfrom
hotfix-winsorize-default
Nov 26, 2026
Merged

jmgirard merged 3 commits into
mainfrom
hotfix-winsorize-default

Conversation

@jmgirard

Copy link
Copy Markdown
Contributor

winsorize() on a data frame failed with "no applicable method" whenever a column had a class without a method, such as Date, POSIXct, or haven_labelled:

winsorize(data.frame(x = c(1:9, 100), date = Sys.Date() + 0:9))
#> Error in UseMethod("winsorize"): no applicable method for 'winsorize' applied to an object of class "Date"

Since winsorize.data.frame() has no select argument, the only way around it was to drop those columns first.

This adds winsorize.default(), which returns the column unchanged with a message, like center.default() and rescale.default(). The message names the column when it comes from a data frame, and verbose = FALSE silences it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are identified, and the change includes targeted regression coverage for preserving unsupported columns and suppressing messages.

No open issues 🎉

1 file not reviewed
  • man/winsorize.Rd: Generated file
What changed in this PR

This PR fixes winsorize() for data frames containing unsupported column classes by preserving those columns unchanged instead of failing S3 dispatch.

Changes:

  • Added winsorize.default() with optional, column-aware messaging and verbose = FALSE support.
  • Added regression coverage for unsupported Date columns and silent mode.
  • Updated documentation, namespace registration, and release notes.
File Description
tests/​testthat/​test-winsorization.R Adds regression tests confirming unsupported Date columns remain unchanged and messages can be suppressed.
R/​winsorize.R Adds the default fallback method and passes data-frame column names for informative messages.
NEWS.md Documents the bug fix for unsupported column classes.
NAMESPACE Registers winsorize.default() as an S3 method.
man/​winsorize.Rd Updates the generated documentation to describe unchanged handling of unsupported variables.

Review effort: Lite

@jmgirard
jmgirard force-pushed the hotfix-winsorize-default branch from a1c457d to f6cf6b2 Compare November 26, 2026 00:40
@jmgirard
jmgirard merged commit 63b539f into main Nov 26, 2026
23 of 26 checks passed
@jmgirard
jmgirard deleted the hotfix-winsorize-default branch November 26, 2026 15:04
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.

3 participants