R/grouped-SpatVector.R

Defines functions is_grouped_spatvector

Documented in is_grouped_spatvector

#' A grouped `SpatVector`
#'
#' @description
#' The easiest way to create a grouped `SpatVector` is to call the
#' `group_by()` method on a `SpatVector`: this will take care of capturing
#' the unevaluated expressions for you. See [group_by.SpatVector()] for details.
#'
#' This function is the adapted version of [dplyr::is_grouped_df()].
#'
#' See also [group_data.SpatVector()] for the accessory functions that retrieve
#' various metadata from a grouped `SpatVector`.
#'
#' @keywords internal
#' @param x a `SpatVector`.
#'
#'
#' @family helpers
#'
#' @export
is_grouped_spatvector <- function(x) {
  att <- attributes(x)

  if (all(att$tblclass == "grouped_df", inherits(att$groups, "tbl_df"))) {
    return(TRUE)
  }

  return(FALSE)
}
dieghernan/tidyterra documentation built on Feb. 20, 2025, 4:18 p.m.