R/head.R

Defines functions head.duckplyr_df

#' @export
head.duckplyr_df <- function(x, n = 6L, ...) {
  stopifnot(is_integerish(n))

  rel_try(call = list(name = "head", x = x, args = list(n = n)),
    "Can't process negative n" = (n < 0),
    {
      rel <- duckdb_rel_from_df(x)
      out_rel <- rel_limit(rel, n)
      out <- rel_to_df(out_rel)
      out <- dplyr_reconstruct(out, x)
      return(out)
    }
  )

  NextMethod()
}

Try the duckplyr package in your browser

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

duckplyr documentation built on Sept. 12, 2024, 9:36 a.m.