R/add_count.R

Defines functions duckplyr_add_count add_count.duckplyr_df

# Generated by 02-duckplyr_df-methods.R
#' @export
add_count.duckplyr_df <- function(x, ..., wt = NULL, sort = FALSE, name = NULL, .drop = deprecated()) {
  # Our implementation
  rel_try(NULL,
    "No relational implementation for add_count()" = TRUE,
    {
      return(out)
    }
  )

  # dplyr forward
  add_count <- dplyr$add_count.data.frame
  out <- add_count(x, ..., wt = {{ wt }}, sort = sort, name = name, .drop = .drop)
  return(out)

  # dplyr implementation
  out <- add_count_impl(
    x,
    ...,
    wt = {{ wt }},
    sort = sort,
    name = name,
    .drop = .drop
  )
  dplyr_reconstruct(out, x)
}

duckplyr_add_count <- function(x, ...) {
  try_fetch(
    x <- as_duckplyr_df(x),
    error = function(e) {
      testthat::skip(conditionMessage(e))
    }
  )
  out <- add_count(x, ...)
  class(out) <- setdiff(class(out), "duckplyr_df")
  out
}
duckdblabs/duckplyr documentation built on Nov. 6, 2024, 10 p.m.