Skip to content

Commit

Permalink
Merge pull request #29 from poissonconsulting/unite-str-sym
Browse files Browse the repository at this point in the history
Fix issue with `unite_str()` not accepting strings and symbols
  • Loading branch information
aylapear authored Jan 22, 2025
2 parents 1507db0 + fdabfb8 commit 4082677
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 2 additions & 1 deletion R/unite-str.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#'
#' unite_str(data, "new", x, y, remove = FALSE)
unite_str <- function(data, col, ..., sep = ". ", remove = TRUE) {
col <- rlang::ensym(col)
if (rlang::dots_n(...) == 0) {
from_vars <- rlang::set_names(seq_along(data), names(data))
} else {
Expand All @@ -26,6 +27,6 @@ unite_str <- function(data, col, ..., sep = ". ", remove = TRUE) {
data <- dplyr::mutate(data, dplyr::across(tidyselect::all_of(from_vars), as.character))
data <- dplyr::mutate(data, dplyr::across(tidyselect::all_of(from_vars), na_if_blank))
data <- tidyr::unite(data, col = !!col, ..., sep = sep, remove = remove, na.rm = TRUE)
data <- dplyr::mutate(data, dplyr::across(tidyselect::all_of(col), na_if_blank))
data <- dplyr::mutate(data, dplyr::across(tidyselect::all_of(rlang::as_string(col)), na_if_blank))
data
}
1 change: 0 additions & 1 deletion tests/testthat/test-unite-str.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ test_that("unite_str works character", {

test_that("unite_str works symbol", {
data <- tibble::tibble(x = c("good", "Saw fish.", NA), y = c("2021", NA, NA))
skip("get unite_str working with symbol!")
data <- unite_str(data, new, x, y)
expect_s3_class(data, "tbl_df")
expect_identical(colnames(data), "new")
Expand Down

0 comments on commit 4082677

Please sign in to comment.