-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from NIFU-NO/dev
Dev
- Loading branch information
Showing
13 changed files
with
195 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
add_max_chars_labels_to_chapter_structure <- | ||
function(chapter_structure, | ||
target_variable = ".variable_label_suffix_dep", | ||
variable_name_max_label_char = ".max_chars_labels_dep") { | ||
if (is.null(chapter_structure[[target_variable]])) { | ||
cli::cli_abort("{.arg target_variable} ({.var {target_variable}}) not found in {.arg chapter_structure}.") | ||
} | ||
|
||
chapter_structure |> | ||
dplyr::mutate("{variable_name_max_label_char}" := max(c(nchar(.data[[target_variable]]), 0), na.rm = TRUE)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
collapse_chapter_structure_to_chr <- function(data, sep=",", sep2=",", last=",", trunc = 30) { | ||
collapse_chapter_structure_to_chr <- function(data, sep = ",", sep2 = ",", last = ",", trunc = 35) { | ||
data |> | ||
dplyr::distinct(dplyr::pick(tidyselect::everything())) |> | ||
lapply(FUN = function(col) { | ||
col <- as.character(col) | ||
uniques <- unique(col) | ||
uniques <- uniques[!is.na(uniques)] | ||
cli::ansi_collapse(uniques, sep=sep, sep2 = sep2, last = last, trunc = trunc, width = Inf) | ||
}) |> | ||
lapply(FUN = function(col) { | ||
col <- as.character(col) | ||
uniques <- unique(col) | ||
uniques <- uniques[!is.na(uniques)] | ||
cli::ansi_collapse(uniques, sep = sep, sep2 = sep2, last = last, trunc = trunc, width = Inf) | ||
}) |> | ||
unlist() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ README | |
RStudio | ||
Rdata | ||
Rds | ||
Rmarkdown | ||
Rproj | ||
Rstudio | ||
Rtools | ||
|
12 changes: 12 additions & 0 deletions
12
tests/testthat/test-add_max_chars_labels_to_chapter_structure.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
testthat::test_that("add_max_chars_labels_to_chapter_structure", { | ||
testthat::expect_equal( | ||
data.frame( | ||
chapter = "1", | ||
.variable_label_suffix_dep = c(NA, "Hello dear!") | ||
) |> | ||
dplyr::group_by(chapter) |> | ||
saros.base:::add_max_chars_labels_to_chapter_structure(), | ||
tibble::tibble(chapter = "1", .variable_label_suffix_dep = c(NA, "Hello dear!"), .max_chars_labels_dep = c(11, 11)) |> | ||
dplyr::group_by(chapter) | ||
) | ||
}) |
Oops, something went wrong.