Skip to content

Commit 94d774c

Browse files
authored
Merge pull request #2125 from olivroy/case-match
remove case_match() usage
2 parents 44e7f88 + 7316cd4 commit 94d774c

File tree

6 files changed

+9
-13
lines changed

6 files changed

+9
-13
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Imports:
3939
bitops (>= 1.0-7),
4040
cli (>= 3.6.3),
4141
commonmark (>= 1.9.1),
42-
dplyr (>= 1.1.4),
42+
dplyr (>= 1.2.0),
4343
fs (>= 1.6.4),
4444
glue (>= 1.8.0),
4545
htmltools (>= 0.5.8.1),
@@ -52,7 +52,7 @@ Imports:
5252
sass (>= 0.4.9),
5353
scales (>= 1.3.0),
5454
tidyselect (>= 1.2.1),
55-
vctrs,
55+
vctrs (>= 0.7.0),
5656
xml2 (>= 1.3.6)
5757
Suggests:
5858
bit64,

R/dt_stub_df.R

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,8 @@ dt_stub_df_init <- function(
141141

142142
unique_row_group_ids <-
143143
create_unique_id_vals(unique_row_group_labels, simplify = process_md)
144-
names(unique_row_group_ids) <- unique_row_group_labels
145144

146-
# dplyr::recode is superseded, and is slower now.
147-
# TODO consider using vctrs::vec_case_match when available r-lib/vctrs#1622
148-
row_group_ids <- dplyr::recode(row_group_labels, !!!unique_row_group_ids)
145+
row_group_ids <- dplyr::replace_values(row_group_labels, from = unique_row_group_ids, to = unique_row_group_labels)
149146

150147
} else {
151148
row_group_ids <- row_group_labels

R/format_data.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5419,11 +5419,11 @@ extract_duration_pattern <- function(
54195419
) {
54205420

54215421
x_val_i_type <-
5422-
dplyr::case_match(
5422+
dplyr::recode_values(
54235423
value,
54245424
1 ~ "one",
54255425
0 ~ "zero",
5426-
.default = "other"
5426+
default = "other"
54275427
)
54285428

54295429
pattern <- patterns[grepl(paste0(sub("s$", "", time_p), ".*?.", x_val_i_type), names(patterns))][[1]]

R/info_tables.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -764,10 +764,9 @@ info_locales <- function(begins_with = NULL) {
764764
)
765765

766766
tab_1$group <-
767-
dplyr::case_match(
767+
dplyr::replace_values(
768768
tab_1$group,
769-
c("\u00a0", "\u202f") ~ "space",
770-
.default = tab_1$group
769+
c("\u00a0", "\u202f") ~ "space"
771770
)
772771

773772
tab_1 <- tab_1[c("locale", "display_name", "group", "decimal")]

R/text_transform.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ text_case_match <- function(
410410

411411
if (.replace == "all") {
412412

413-
x <- dplyr::case_match(.x = unlist(x), !!!x_list, .default = unlist(.default))
413+
x <- dplyr::recode_values(x = unlist(x), !!!x_list, default = unlist(.default))
414414

415415
} else {
416416

R/utils_examples.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ write_gt_examples_qmd_files <- function(
283283
)
284284
) |>
285285
dplyr::mutate(
286-
group = dplyr::case_match(family,
286+
group = dplyr::recode_values(family,
287287
1 ~ "Table creation",
288288
2 ~ "Creating or modifying parts of a table",
289289
3 ~ "Formatting column data",

0 commit comments

Comments
 (0)