Permalink
Browse files

Remove unneeded util functions

  • Loading branch information...
1 parent 8ce522a commit 1bc4d1e179536e3404418a9589d982c242a40793 @hadley hadley committed Dec 10, 2011
Showing with 0 additions and 107 deletions.
  1. +0 −2 DESCRIPTION
  2. +0 −29 R/utilities-discrete.r
  3. +0 −25 R/utilities-facet.r
  4. +0 −51 R/utilities-grid.r
View
@@ -173,8 +173,6 @@ Collate:
'theme-elements.r'
'theme.r'
'utilities-break.r'
- 'utilities-discrete.r'
- 'utilities-facet.r'
'utilities-grid.r'
'utilities-layer.r'
'utilities-matrix.r'
View
@@ -1,29 +0,0 @@
-# Calculate range for discrete position variables
-# This is the equivalent of range for discrete variables
-#
-# @keyword internal
-discrete_range <- function(..., drop = FALSE) {
- pieces <- list(...)
-
- clevels <- function(x) {
- if (is.null(x)) return(character())
-
- if (is.factor(x)) {
- if (drop) x <- factor(x)
- values <- levels(x)
- } else if (is.numeric(x)) {
- values <- unique(x)
- } else {
- values <- as.character(unique(x))
- }
- if (any(is.na(x))) values <- c(values, NA)
- values
- }
- all <- unique(unlist(lapply(pieces, clevels)))
- if (is.numeric(all)) {
- all <- all[order(all)]
- all <- as.character(all)
- }
-
- all
-}
View
@@ -1,25 +0,0 @@
-# Adding missing levels
-# Ensure all data frames in list have same levels for selected variables
-#
-# @keyword internal
-add_missing_levels <- function(dfs, levels) {
-
- lapply(dfs, function(df) {
- for(var in intersect(names(df), names(levels))) {
- df[var] <- factor(df[, var], levels = ulevels(levels[[var]]))
- }
- df
- })
-}
-
-# Unique levels
-# Get unique levels of vector
-#
-# @keyword internal
-ulevels <- function(x) {
- if (is.factor(x)) {
- levels(factor(x))
- } else {
- sort(unique(x))
- }
-}
View
@@ -7,14 +7,6 @@ ggname <- function(prefix, grob) {
grob
}
-# Global grob editing
-# To match grid.gedit
-#
-# @keyword internal
-geditGrob <- function(..., grep = TRUE, global = TRUE) {
- editGrob(..., grep = grep, global = global)
-}
-
width_cm <- function(x) {
if (is.grob(x)) {
convertWidth(grobWidth(x), "cm", TRUE)
@@ -37,46 +29,3 @@ height_cm <- function(x) {
stop("Unknown input")
}
}
-
-# Grob row heights
-# Given a matrix of grobs, calculate the height needed for each row
-#
-# @param matrix of grobs
-# @keyword internal
-grobRowHeight <- function(mat) {
- row_heights <- alply(mat, 1, function(x) llply(x, grobHeight))
- do.call("unit.c", llply(row_heights, splat(max)))
-}
-
-# Grob column widths
-# Given a matrix of grobs, calculate the width needed for each column
-#
-# @param matrix of grobs
-# @keyword internal
-grobColWidth <- function(mat) {
- col_widths <- alply(mat, 2, function(x) llply(x, grobWidth))
- do.call("unit.c", llply(col_widths, splat(max)))
-}
-
-# Build grob matrix
-# Build a matrix of grobs given a vector of grobs and the desired dimensions of the matrix
-#
-# Any missing cells at the end will be filled in with zeroGrobs.
-#
-# @param vector of grobs
-# @param number of rows
-# @param number of columns
-# @param should the matrix be arranged like a table or a plot
-# @keyword internal
-grobMatrix <- function(vec, nrow, ncol, as.table = FALSE) {
- if (nrow == 0 || ncol == 0) {
- return(matrix(ncol = ncol, nrow = nrow))
- }
-
- mat <- c(vec, rep(list(zeroGrob()), nrow * ncol - length(vec)))
- dim(mat) <- c(ncol, nrow)
- mat <- t(mat)
- if (!as.table) mat <- mat[rev(seq_len(nrow)), ]
-
- mat
-}

0 comments on commit 1bc4d1e

Please sign in to comment.