Skip to content

Commit

Permalink
replace datawizard::data_unite and datawizard::data_rename with gsub …
Browse files Browse the repository at this point in the history
…and setNames
  • Loading branch information
rempsyc committed Dec 12, 2024
1 parent b29eb47 commit 2c69b3e
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions R/report_sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Check warning on line 180 in R/report_sample.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/report_sample.R,line=180,col=27,[fixed_regex_linter] Use "." with fixed = TRUE here. This regular expression is static, i.e., its matches can be expressed as a fixed substring expression, which is faster to compute.
result <- setNames(result, group_names)
}
# remember values of first columns
variable <- result[[1]]["Variable"]
Expand Down

0 comments on commit 2c69b3e

Please sign in to comment.