R/original.R

Defines functions ggplot2_strip_dots ggplot2_is_calculated_aes ggplot2_is.constant

## to reduce burden to import too much packages
## I redfined/move functions in some other packages to here
.all_aesthetics <- c("adj", "alpha", "angle", "bg", "cex", "col",  "color", "colour", "fg",
                     "fill", "group", "hjust",  "label", "linetype", "lower", "lty",
                     "lwd",  "max", "middle", "min", "order", "pch", "radius", "sample",
                     "shape" , "size",  "srt",  "upper", "vjust", "weight", "width",
                     "x" ,  "xend", "xmax", "xmin", "xintercept",  "y",
                     "yend", "ymax", "ymin", "yintercept",  "z")

ggplot2_is.constant <- function(x){
    sapply(x, function(x) "I" %in% all.names(asOneSidedFormula(x)))
}

## for ggplot2
ggplot2_is_calculated_aes <- function(aesthetics){
  match <- "\\.\\.([a-zA-z._]+)\\.\\."
  stats <- rep(FALSE, length(aesthetics))
  grepl(match, sapply(aesthetics, quo_text))
}


ggplot2_strip_dots <- function(aesthetics){
  match <- "\\.\\.([a-zA-z._]+)\\.\\."
  strings <- lapply(aesthetics, quo_text)
  strings <- lapply(strings, gsub, pattern = match, replacement = "\\1")
  lapply(strings, function(x) parse(text = x)[[1]])
}

Try the biovizBase package in your browser

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

biovizBase documentation built on Nov. 8, 2020, 8:01 p.m.