R/utils_select.R

Defines functions .obj_has_name .rownames_as_column string_ends_with

#' @keywords internal
string_ends_with <- function(pattern, x) {
  pattern <- paste0("\\Q", pattern, "\\E$")
  grep(pattern, x, perl = TRUE)
}

#' @keywords internal
.rownames_as_column <- function(x, var = "rowname") {
  rn <- data.frame(rn = rownames(x), stringsAsFactors = FALSE)
  x <- cbind(rn, x)
  colnames(x)[1] <- var
  rownames(x) <- NULL
  x
}

#' @keywords internal
.obj_has_name <- function(x, name) {
  name %in% names(x)
}
strengejacke/ggeffects documentation built on Dec. 24, 2024, 3:27 a.m.