R/remap_id.R

Defines functions remap_id

Documented in remap_id

#' Remap identifiers
#'
#' Remap identifiers
#'
#' @importFrom rlang :=
#' @keywords internal
remap_id <- function(lst_tbls, old, new) {
  id_mapping <-
    lst_tbls[[1]] %>%
    dplyr::select('..page', 'array.index', {{ old }}) %>%
    dplyr::rename({{ new }} := {{ old }})

  purrr::map(
    lst_tbls,
    ~ dplyr::left_join(., id_mapping, by = c('..page', 'array.index')) %>%
      dplyr::select(-any_of(c('document.id', 'array.index', {{old}}))) %>%
      suppressWarnings() %>%
      dplyr::relocate({{ new }}, .before = 1L)
  ) %>% return()

}

Try the quincunx package in your browser

Any scripts or data that you put into this service are public.

quincunx documentation built on July 9, 2023, 7:32 p.m.