From 1ee2f8065f5e326e1b08c3f713649a82973f9fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Th=C3=A9riault?= <13123390+rempsyc@users.noreply.github.com> Date: Thu, 12 Dec 2024 18:59:04 -0500 Subject: [PATCH] replace `datawizard::data_rename` (#474) * replace datawizard::data_unite and datawizard::data_rename with gsub and setNames * namespace stats::setNames * put back datawizard::data_unite and use alternative trick to match order --- R/report_sample.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/R/report_sample.R b/R/report_sample.R index 14918e28..761a1cd2 100644 --- a/R/report_sample.R +++ b/R/report_sample.R @@ -181,13 +181,16 @@ report_sample <- function(data, unique(groups), new_column = ".old_names", separator = "." - )[[".old_names"]] + )[".old_names"] + new_names <- datawizard::data_unite( unique(groups), new_column = ".new_names", separator = ", " - )[[".new_names"]] - result <- datawizard::data_rename(result, pattern = old_names, replacement = new_names) + )[".new_names"] + + name_map <- stats::setNames(new_names[[1]], old_names[[1]]) + names(result) <- name_map[names(result)] } # remember values of first columns variable <- result[[1]]["Variable"]