-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Override default density method (#5358)
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
# In R devel from 4.3.0 onwards, the density calculation has slightly changed, | ||
# which affects visual snapshots that use a density calculation, like | ||
# `geom_violin()` and `geom_density()`. | ||
# See https://developer.r-project.org/blosxom.cgi/R-devel/NEWS/2023/05/03#n2023-05-03 | ||
# | ||
# It has a backwards compatibility argument called 'old.coords' that can be used | ||
# to perform the classic density calculation, which means we can stably use | ||
# visual tests in R devel. | ||
# | ||
# Since that argument is not available in older versions, we have to use the | ||
# following workaround. Here, we conditionally override the default | ||
# density method to use `old.coords = TRUE`. | ||
if ("old.coords" %in% names(formals(stats::density.default))) { | ||
registerS3method( | ||
"density", "default", | ||
function(..., old.coords = TRUE) { | ||
stats::density.default(..., old.coords = old.coords) | ||
} | ||
) | ||
} |