R/util.R

Defines functions remove_time_group make_dummy_dispatch_obj index_attributes string_length glue_stop

# Reexports --------------------------------------------------------------------

#' @importFrom dplyr %>%
#' @export
#'
dplyr::`%>%`

#' @importFrom rlang :=
#'
NULL

#' @importFrom rlang .data
#'
NULL

#' @importFrom rlang %||%
#'
NULL

#' @useDynLib tibbletime, .registration = TRUE
#' @importFrom Rcpp sourceCpp
NULL

# Global util ------------------------------------------------------------------

# A glue version of stop()
glue_stop <- function(..., .sep = "") {
  stop(glue::glue(..., .sep, .envir = parent.frame()), call. = FALSE)
}

# Cheaply get the length of a string
string_length <- function(x) {
  split <- unlist(strsplit(x, ""))
  length(split)
}

index_attributes <- function() {
  c("index_quo", "index_time_zone")
}

make_dummy_dispatch_obj <- function(x) {
  structure(list(), class = x)
}

remove_time_group <- function(x) {
  if(".time_group" %in% colnames(x)) {
    x[[".time_group"]] <- NULL
  }
  x
}

Try the tibbletime package in your browser

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

tibbletime documentation built on Feb. 16, 2023, 7:09 p.m.