diff --git a/R/unite-str.R b/R/unite-str.R index 941d622..29ad435 100644 --- a/R/unite-str.R +++ b/R/unite-str.R @@ -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 { @@ -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 } diff --git a/tests/testthat/test-unite-str.R b/tests/testthat/test-unite-str.R index c153925..59f47c3 100644 --- a/tests/testthat/test-unite-str.R +++ b/tests/testthat/test-unite-str.R @@ -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")