From cb6f54401e6ad741749af0ed95f6e722b2abd622 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 23 May 2024 18:18:55 +0200 Subject: [PATCH 1/2] Use stable version of `{purrrr}` --- DESCRIPTION | 2 +- R/compat-dplyr.R | 6 ------ R/visit.R | 5 +++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1015146f4..eff06662c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,7 +27,7 @@ Depends: Imports: cli (>= 3.1.1), magrittr (>= 2.0.0), - purrr (>= 0.2.3), + purrr (>= 1.0.2), R.cache (>= 0.15.0), rlang (>= 1.0.0), rprojroot (>= 1.1), diff --git a/R/compat-dplyr.R b/R/compat-dplyr.R index 340810003..00b08610b 100644 --- a/R/compat-dplyr.R +++ b/R/compat-dplyr.R @@ -51,9 +51,3 @@ left_join <- function(x, y, by) { last <- function(x) { x[[length(x)]] } - -map_dfr <- function(.x, .f, ...) { - .f <- purrr::as_mapper(.f, ...) - res <- map(.x, .f, ...) - vec_rbind(!!!res) -} diff --git a/R/visit.R b/R/visit.R index 1d048bbfa..6fd0d5a97 100644 --- a/R/visit.R +++ b/R/visit.R @@ -233,10 +233,11 @@ enrich_terminals <- function(flattened_pd, use_raw_indention = FALSE) { groups <- flattened_pd$line1 split_pd <- vec_split(flattened_pd, groups)[[2L]] flattened_pd <- split_pd %>% - map_dfr(function(.x) { + purrr::map(function(.x) { .x$col2 <- cumsum(.x$nchar + .x$lag_spaces) .x - }) + }) %>% + purrr::list_rbind() flattened_pd$col1 <- flattened_pd$col2 - flattened_pd$nchar flattened_pd } From 9e9d8eca8ffcafdb9441574b873d5f093be55837 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 23 May 2024 18:23:48 +0200 Subject: [PATCH 2/2] remove unused `arrange()` --- R/compat-dplyr.R | 6 ------ 1 file changed, 6 deletions(-) diff --git a/R/compat-dplyr.R b/R/compat-dplyr.R index 00b08610b..1d8d6623e 100644 --- a/R/compat-dplyr.R +++ b/R/compat-dplyr.R @@ -10,12 +10,6 @@ lead <- function(x, n = 1L, default = NA) { c(x[-seq_len(n)], rep(default, n)) } - -arrange <- function(.data, ...) { - ord <- eval(substitute(order(...)), .data, parent.frame()) - vec_slice(.data, ord) -} - arrange_pos_id <- function(data) { pos_id <- data$pos_id if (is.unsorted(pos_id)) {