File: utilities-help.r

package info (click to toggle)
r-cran-ggplot2 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,412 kB
  • sloc: sh: 9; makefile: 1
file content (30 lines) | stat: -rw-r--r-- 934 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
aesthetics <- function(x) {
  req_aes <- x$required_aes
  def_aes <- names(x$default_aes())
  def_aes <- setdiff(def_aes, req_aes)
  if (length(req_aes) == 0){
    # Suppress warnings which occur when sorting NULL
    return(suppressWarnings(sort(names(x$default_aes()))))
  }
  if (length(def_aes) == 0){
    return(paste("\\strong{", sort(x$required_aes), "}",sep = ""))
  }
  return(c(paste("\\strong{", sort(x$required_aes), "}", sep = ""), sort(def_aes)))
}
geom_aesthetics <- function(x) {
  aesthetics(Geom$find(x))
}
stat_aesthetics <- function(x) {
  aesthetics(Stat$find(x))
}

rd_aesthetics <- function(type, name) {
  obj <- get(firstUpper(type))
  aes <- aesthetics(obj$find(name))

  paste("\\code{", type, "_", name, "} ",
    "understands the following aesthetics (required aesthetics are in bold):\n\n",
    "\\itemize{\n",
    paste("  \\item \\code{", aes, "}", collapse = "\n", sep = ""),
    "\n}\n", sep = "")
}