From ae17dfa594a93ceb78810f8e6147a3e3813d22bc Mon Sep 17 00:00:00 2001 From: Davis Vaughan Date: Fri, 9 Jan 2026 15:38:23 -0500 Subject: [PATCH] Avoid outdated dplyr functions --- R/buildMatrix.r | 8 +------- R/impute.r | 3 +-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/R/buildMatrix.r b/R/buildMatrix.r index f7af1bf..008525f 100644 --- a/R/buildMatrix.r +++ b/R/buildMatrix.r @@ -81,13 +81,7 @@ build.x <- function(formula, data, contrasts=TRUE, sparse=FALSE) { # convert to factor # data[, charIndex] <- plyr::catcolwise(as.factor)(data[, charIndex, drop=FALSE]) - if(utils::packageVersion('dplyr') <= '0.5.0') - { - data <- dplyr::mutate_at(data, .cols=charIndex, as.factor) - } else if(utils::packageVersion('dplyr') >= '0.6.0') - { - data <- dplyr::mutate_at(data, .vars=charIndex, as.factor) - } + data <- dplyr::mutate(data, dplyr::across(dplyr::all_of(charIndex), as.factor)) ## now all factors or characters are at least factors (and nothing extraneous was done) and only the appropriate columns will be put into the contrasts argument } diff --git a/R/impute.r b/R/impute.r index ae2d10c..a760608 100644 --- a/R/impute.r +++ b/R/impute.r @@ -82,8 +82,7 @@ simple.impute.default <- function(x, fun=median, ...) #' simple.impute.data.frame <- function(x, fun=stats::median, ...) { - . <- NULL - dplyr::mutate_at(x, .cols=names(x), .funs=~simple.impute(., fun=fun)) + dplyr::mutate(x, dplyr::across(dplyr::everything(), ~simple.impute(.x, fun=fun))) } #' @title simple.impute.tbl_df