From 2c69b3e489689e3a7d61aa8bcd168cb77519ef3a 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:19:23 -0500 Subject: [PATCH] replace datawizard::data_unite and datawizard::data_rename with gsub and setNames --- R/report_sample.R | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/R/report_sample.R b/R/report_sample.R index 14918e28..93bd97b1 100644 --- a/R/report_sample.R +++ b/R/report_sample.R @@ -177,17 +177,8 @@ report_sample <- function(data, # for more than one group, fix column names. we don't want "a.b (n=10)", # but rather ""a, b (n=10)"" if (length(by) > 1) { - old_names <- datawizard::data_unite( - unique(groups), - new_column = ".old_names", - separator = "." - )[[".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) + group_names <- gsub("[.]", ", ", names(result)) + result <- setNames(result, group_names) } # remember values of first columns variable <- result[[1]]["Variable"]