Permalink
Browse files

Add wrapper function for plyr::rename so it works with old and new ve…

…rsion

Also change the Imports version of plyr so that it works with old and new
version.
  • Loading branch information...
1 parent c768108 commit ee8ec2a291a55ef481f2efe45cc809d1e3a46c24 @wch wch committed Oct 18, 2012
Showing with 22 additions and 16 deletions.
  1. +1 −1 DESCRIPTION
  2. +1 −8 R/aes.r
  3. +1 −1 R/coord-munch.r
  4. +2 −2 R/coord-polar.r
  5. +2 −1 R/geom-segment.r
  6. +1 −1 R/stat-density.r
  7. +1 −1 R/stat-sum.r
  8. +2 −1 R/stat-summary.r
  9. +11 −0 R/utilities.r
View
@@ -18,7 +18,7 @@ Depends:
stats,
methods
Imports:
- plyr (>= 1.7.1.99.1),
+ plyr (>= 1.7.1),
digest,
grid,
gtable (>= 0.1.1),
View
@@ -65,14 +65,7 @@ rename_aes <- function(x) {
full <- match(names(x), .all_aesthetics)
names(x)[!is.na(full)] <- .all_aesthetics[full[!is.na(full)]]
- # This is a hack for ggplot2 0.9.3 to make it compatible with both plyr 1.7.1 and
- # plyr 1.8 (and above). This should be removed for the next release of ggplot2.
- # Tag: deprecated
- if (packageVersion("plyr") <= package_version("1.7.1")) {
- rename(x, .base_to_ggplot)
- } else {
- rename(x, .base_to_ggplot, warn_missing = FALSE)
- }
+ rename(x, .base_to_ggplot, warn_missing = FALSE)
}
# Look up the scale that should be used for a given aesthetic
View
@@ -98,7 +98,7 @@ dist_polar <- function(r, theta) {
# Note that 'slope' actually means the spiral slope, 'a' in the spiral
# formula r = a * theta
lf <- rename(lf, c(x1 = "t1", x2 = "t2", y1 = "r1", y2 = "r2",
- yintercept = "r_int", xintercept = "t_int"))
+ yintercept = "r_int", xintercept = "t_int"), warn_missing = FALSE)
# Re-normalize the theta values so that intercept for each is 0
# This is necessary for calculating spiral arc length.
View
@@ -125,9 +125,9 @@ coord_train.polar <- function(coord, scales) {
rename_data <- function(coord, data) {
if (coord$theta == "y") {
- rename(data, c("y" = "theta", "x" = "r"))
+ rename(data, c("y" = "theta", "x" = "r"), warn_missing = FALSE)
} else {
- rename(data, c("y" = "r", "x" = "theta"))
+ rename(data, c("y" = "r", "x" = "theta"), warn_missing = FALSE)
}
}
View
@@ -70,7 +70,8 @@ GeomSegment <- proto(Geom, {
data$group <- 1:nrow(data)
starts <- subset(data, select = c(-xend, -yend))
- ends <- rename(subset(data, select = c(-x, -y)), c("xend" = "x", "yend" = "y"))
+ ends <- rename(subset(data, select = c(-x, -y)), c("xend" = "x", "yend" = "y"),
+ warn_missing = FALSE)
pieces <- rbind(starts, ends)
pieces <- pieces[order(pieces$group),]
View
@@ -114,7 +114,7 @@ StatDensity <- proto(Stat, {
if (trim) densdf <- subset(densdf, x > min(data$x, na.rm = TRUE) & x < max(data$x, na.rm = TRUE))
densdf$count <- densdf$y * n
- rename(densdf, c(y = "density"))
+ rename(densdf, c(y = "density"), warn_missing = FALSE)
}
default_geom <- function(.) GeomArea
View
@@ -63,7 +63,7 @@ StatSum <- proto(Stat, {
group_by <- setdiff(intersect(names(data), .all_aesthetics), "weight")
counts <- count(data, group_by, wt_var = "weight")
- counts <- rename(counts, c(freq = "n"))
+ counts <- rename(counts, c(freq = "n"), warn_missing = FALSE)
counts$prop <- ave(counts$n, counts$group, FUN = prop.table)
counts
}
View
@@ -185,7 +185,8 @@ wrap_hmisc <- function(fun) {
result <- safe.call(fun, list(x = x, ...))
rename(
data.frame(t(result)),
- c(Median = "y", Mean = "y", Lower = "ymin", Upper = "ymax")
+ c(Median = "y", Mean = "y", Lower = "ymin", Upper = "ymax"),
+ warn_missing = FALSE
)
}
}
View
@@ -184,3 +184,14 @@ rescale01 <- function(x) {
rng <- range(x, na.rm = TRUE)
(x - rng[1]) / (rng[2] - rng[1])
}
+
+# This is a hack for ggplot2 0.9.3 to make it compatible with both plyr 1.7.1 and
+# plyr 1.8 (and above). This should be removed for the next release of ggplot2.
+# Tag: deprecated
+if (packageVersion("plyr") <= package_version("1.7.1")) {
+ rename <- function(x, replace, warn_missing) {
+ plyr::rename(x, replace)
+ }
+} else {
+ rename <- plyr::rename
+}

0 comments on commit ee8ec2a

Please sign in to comment.