tests/testthat/helper-unknown-rows.R

as_unknown_rows <- function(x) {
  x <- as_tbl(x)
  class(x) <- c("unknown_rows", "tbl")
  x
}

local_unknown_rows <- function(frame = caller_env()) {
  local_methods(
    .frame = frame,
    as.data.frame.unknown_rows = function(x, ...) {
      class(x) <- "data.frame"
      x
    },
    dim.unknown_rows = function(x) {
      c(NA_integer_, length(x))
    },
    head.unknown_rows = function(x, n) {
      class(x) <- "data.frame"
      head(x, n)
    }
  )
}

Try the pillar package in your browser

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

pillar documentation built on March 31, 2023, 10:19 p.m.