r-lib / rematch2
Showing 2 of 13 files from the diff.

@@ -5,10 +5,8 @@
Loading
5 5
#' groups from the match of a regular expression to a character vector.
6 6
#' See \code{\link{re_match}}.
7 7
#'
8 -
#' @docType package
9 -
#' @name rematch2
10 -
#' @importFrom tibble tibble
11 -
NULL
8 +
#' @importFrom tibble tibble new_tibble
9 +
"_PACKAGE"
12 10
13 11
#' Extract Regular Expression Matches Into a Data Frame
14 12
#'

@@ -75,18 +75,16 @@
Loading
75 75
76 76
  names <- c("match", "start", "end")
77 77
78 -
  matchlist <- structure(
78 +
  matchlist <- new_rematch_records(
79 79
    lapply(seq_along(text), function(i) {
80 80
      structure(list(matchstr[i], start[i], end[i]), names = names)
81 -
    }),
82 -
    class = "rematch_records"
81 +
    })
83 82
  )
84 83
85 -
  res <- structure(
84 +
  res <- new_tibble(
86 85
    list(text, matchlist),
87 86
    names = c(".text", ".match"),
88 -
    row.names = seq_along(text),
89 -
    class = c("tbl_df", "tbl", "data.frame")
87 +
    nrow = length(text)
90 88
  )
91 89
92 90
  if (!is.null(attr(match, "capture.start"))) {
@@ -104,25 +102,27 @@
Loading
104 102
    grouplists <- lapply(
105 103
      seq_along(attr(match, "capture.names")),
106 104
      function(g) {
107 -
        structure(
105 +
        new_rematch_records(
108 106
          lapply(seq_along(text), function(i) {
109 107
            structure(
110 108
              list(groupstr[i, g], gstart[i, g], gend[i, g]),
111 109
              names = names
112 110
            )
113 -
          }),
114 -
          class = "rematch_records"
111 +
          })
115 112
        )
116 113
      }
117 114
    )
118 115
119 -
    res <- structure(
116 +
    res <- new_tibble(
120 117
      c(grouplists, res),
121 118
      names = c(attr(match, "capture.names"), ".text", ".match"),
122 -
      row.names = seq_along(text),
123 -
      class = c("tbl_df", "tbl", "data.frame")
119 +
      nrow = length(res[[1]])
124 120
    )
125 121
  }
126 122
127 123
  res
128 124
}
125 +
126 +
new_rematch_records <- function(x) {
127 +
  structure(x, class = c("rematch_records", "list"))
128 +
}
Files Coverage
R 99.44%
Project Totals (7 files) 99.44%
Notifications are pending CI completion. Waiting for GitHub's status webhook to queue notifications. Push notifications now.
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading