Skip to content

Commit

Permalink
put back datawizard::data_unite and use alternative trick to match order
Browse files Browse the repository at this point in the history
  • Loading branch information
rempsyc committed Dec 12, 2024
1 parent 9ae6a8a commit 37e1ed0
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions R/report_sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,20 @@ 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) {
group_names <- gsub("[.]", ", ", names(result))
result <- stats::setNames(result, group_names)
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"]

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"]
Expand Down

0 comments on commit 37e1ed0

Please sign in to comment.