Skip to content

Commit

Permalink
replace datawizard::data_rename (#474)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rempsyc authored Dec 12, 2024
1 parent b29eb47 commit 1ee2f80
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions R/report_sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 1ee2f80

Please sign in to comment.