R/nest_by.R

Defines functions duckplyr_nest_by nest_by.duckplyr_df

# Generated by 02-duckplyr_df-methods.R
#' @export
nest_by.duckplyr_df <- function(.data, ..., .key = "data", .keep = FALSE) {
  # Our implementation
  rel_try(NULL,
    "No relational implementation for nest_by()" = TRUE,
    {
      return(out)
    }
  )

  # dplyr forward
  nest_by <- dplyr$nest_by.data.frame
  out <- nest_by(.data, ..., .key = .key, .keep = .keep)
  return(out)

  # dplyr implementation
  .data <- group_by(.data, ...)
  # nest_by.grouped_df(.data, .key = .key, .keep = .keep)
}

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