Skip to content

Conversation

@klin333
Copy link
Contributor

@klin333 klin333 commented Jan 20, 2026

This problem of not explicitly putting stats:: in front of stats package functions was previously documented in #5186. Previously the fix was done in eg #5514

This PR is similar, cleaning up more calls to stats functions that do not have stats:: in front of them.

@klin333
Copy link
Contributor Author

klin333 commented Feb 3, 2026

hi maintainers, maybe @teunbrand? Could you help allow this merge. the check failures seems unrelated to this PR, though i'm not sure... thank you.

@Breeze-Hu
Copy link

Did the previous PR replace stats::ave with vec_ave? #6698
Is this missing? Rather than using stats::ave?

@teunbrand
Copy link
Collaborator

@Breeze-Hu is right. Instead of prefixing the ave() function, can you replace it with vec_ave() instead?

@klin333
Copy link
Contributor Author

klin333 commented Feb 3, 2026

thanks guys, but i don't think it's a simple replace for those remaining stats::ave to vec_ave

These remaining stats::ave has multiple grouping variables, but the vec_ave only supports 1 grouping variable

ggplot2/R/position-dodge.R

Lines 152 to 154 in 1052371

data$order <- xtfrm( # xtfrm makes anything 'sortable'
data$order %||% ave(data$group, data$x, data$PANEL, FUN = match_sorted)
)

ggplot2/R/utilities.R

Lines 938 to 947 in 1052371

vec_ave <- function(x, by, fn, ...) {
idx <- vec_group_loc(by)$loc
list_unchop(
lapply(
vec_chop(x, indices = idx),
FUN = fn, ...
),
indices = idx
)
}

I think this PR is unrelated the to stats::ave -> vec_ave change from #6698. Any way we can allow this PR through without being blocked by these unrelated changes? Ideally there should be a continuation of #6698 separately, assuming that PR simply missed these stats::ave, again probably because these weren't prefixed with stats::.

This forgetting of prefixing stats:: just keeps creeping up year after year, to the point where perhaps it's better to just import all of stats, or configure testthat to run all test suite without stats imported at R startup. But that's above my pay grade, probably @teunbrand

## usethis namespace: start
#' @import scales grid gtable rlang vctrs
#' @importFrom lifecycle deprecated
#' @importFrom stats setNames
#' @importFrom utils head tail
## usethis namespace: end
NULL

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