R/n_groups.R

Defines functions duckplyr_n_groups n_groups.duckplyr_df

# Generated by 02-duckplyr_df-methods.R
#' @export
n_groups.duckplyr_df <- function(x) {
  # Our implementation
  rel_try(
    # Always fall back to dplyr
    "No relational implementation for n_groups()" = TRUE,
    {
      return(out)
    }
  )

  # dplyr forward
  n_groups <- dplyr$n_groups.data.frame
  out <- n_groups(x)
  return(out)

  # dplyr implementation
  nrow(group_data(x))
}

duckplyr_n_groups <- function(x, ...) {
  try_fetch(
    x <- as_duckplyr_df(x),
    error = function(e) {
      testthat::skip(conditionMessage(e))
    }
  )
  out <- n_groups(x, ...)
  class(out) <- setdiff(class(out), "duckplyr_df")
  out
}

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.