Переглянути джерело

factor out need for tidyr

main
Garrick Aden-Buie 6 роки тому
джерело
коміт
3159fd49ce
3 змінених файлів з 8 додано та 9 видалено
  1. +0
    -1
      DESCRIPTION
  2. +7
    -6
      R/regex.R
  3. +1
    -2
      R/utils.R

+ 0
- 1
DESCRIPTION Переглянути файл

@@ -39,7 +39,6 @@ Imports:
rstudioapi,
shiny (>= 0.13),
stringi,
tidyr,
utils
Suggests:
jsonlite,

+ 7
- 6
R/regex.R Переглянути файл

@@ -83,8 +83,10 @@ wrap_result <- function(x, escape = FALSE, exact = FALSE) {
.data$start <= !!inserts$start[j] & .data$end >= !!inserts$end[j])
inserts[j, 'pad'] <- inserts$pad[j] + nrow(overlap)
}
inserts <- inserts %>%
tidyr::gather(type, loc, start:end) %>%
inserts <- dplyr::bind_rows(
inserts %>% select(-.data$end, dplyr::everything(), loc = .data$start) %>% mutate(type = "start"),
inserts %>% select(-.data$start, dplyr::everything(), loc = .data$end) %>% mutate(type = "end")
) %>%
filter(!is.na(.data$loc)) %>%
dplyr::arrange(loc, class, dplyr::desc(type)) %>%
mutate(
@@ -95,10 +97,9 @@ wrap_result <- function(x, escape = FALSE, exact = FALSE) {
inserts <- if (max(inserts$pass) == 1) {
collapse_span_inserts(inserts)
} else {
inserts %>%
tidyr::nest(spans = -.data$pass) %>%
mutate(spans = purrr::map(.data$spans, collapse_span_inserts)) %>%
tidyr::unnest(.data$spans) %>%
split(inserts, inserts$pass) %>%
purrr::map(collapse_span_inserts) %>%
dplyr::bind_rows() %>%
group_by(.data$loc, .data$type) %>%
summarize(insert = paste(.data$insert, collapse = "")) %>%
dplyr::ungroup()

+ 1
- 2
R/utils.R Переглянути файл

@@ -13,5 +13,4 @@ escape_backslash <- function(x) {
gsub("\\\\", "\\\\\\\\", x)
}

# avoid CRAN note for tidyr::gather in wrap_results
utils::globalVariables(c("end", "loc", "start", "type"))
utils::globalVariables(c("loc", "type"))

Завантаження…
Відмінити
Зберегти