Permalink
Browse files

Namespace fixes for examples

  • Loading branch information...
hadley committed Dec 29, 2011
1 parent 5010603 commit d4845c8204f9461f867004e89221bde5178cab46
@@ -40,8 +40,8 @@
#' df <- data.frame(x = rnorm(5000), y = rnorm(5000))
#' h <- ggplot(df, aes(x,y))
#' h + geom_point()
-#' h + geom_point(colour = alpha("black", .5))
-#' h + geom_point(colour = alpha("black", 1/10))
+#' h + geom_point(alpha = 0.5)
+#' h + geom_point(alpha = 1/10)
#'
#' #If a geom uses both fill and colour, alpha will only modify the fill colour
#' c + geom_bar(fill = "dark grey", colour = "black")
@@ -54,5 +54,6 @@
#' j <- j + geom_rect(aes(NULL, NULL, xmin = start, xmax = end, fill = party),
#' ymin = yrng[1], ymax = yrng[2], data = presidential)
#' j
+#' library(scales) # to access the alpha function
#' j + scale_fill_manual(values = alpha(c("blue", "red"), .3))
NULL
View
@@ -16,7 +16,7 @@ NULL
#' annotation_map(usamap, fill = "NA", colour = "grey50") +
#' geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat))
#'
-#' seal2 <- mutate(seal.sub,
+#' seal2 <- transform(seal.sub,
#' latr = cut(lat, 2),
#' longr = cut(long, 2))
#'
View
@@ -77,6 +77,7 @@ map_data <- function(map, region = ".", exact = FALSE, ...) {
#'
#' ia <- map_data("county", "iowa")
#' mid_range <- function(x) mean(range(x))
+#' library(plyr)
#' seats <- ddply(ia, .(subregion), colwise(mid_range, .(lat, long)))
#' ggplot(ia, aes(long, lat)) +
#' geom_polygon(aes(group = group), fill = NA, colour = "grey60") +
View
@@ -12,7 +12,7 @@
#' library(plyr)
#' ecm <- melt(economics, id = "date")
#' rescale01 <- function(x) (x - min(x)) / diff(range(x))
-#' ecm <- ddply(ecm, "variable", mutate, value = rescale01(value))
+#' ecm <- ddply(ecm, "variable", transform, value = rescale01(value))
#'
#' qplot(date, value, data=ecm, geom="line", group=variable)
#' qplot(date, value, data=ecm, geom="line", linetype=variable)
@@ -43,8 +43,8 @@ b + geom_point(colour = "red")
df <- data.frame(x = rnorm(5000), y = rnorm(5000))
h <- ggplot(df, aes(x,y))
h + geom_point()
-h + geom_point(colour = alpha("black", .5))
-h + geom_point(colour = alpha("black", 1/10))
+h + geom_point(alpha = 0.5)
+h + geom_point(alpha = 1/10)
#If a geom uses both fill and colour, alpha will only modify the fill colour
c + geom_bar(fill = "dark grey", colour = "black")
@@ -57,6 +57,7 @@ yrng <- range(economics$unemploy)
j <- j + geom_rect(aes(NULL, NULL, xmin = start, xmax = end, fill = party),
ymin = yrng[1], ymax = yrng[2], data = presidential)
j
+library(scales) # to access the alpha function
j + scale_fill_manual(values = alpha(c("blue", "red"), .3))
}
View
@@ -23,7 +23,7 @@ ggplot(seal.sub, aes(x = long, y = lat)) +
annotation_map(usamap, fill = "NA", colour = "grey50") +
geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat))
-seal2 <- mutate(seal.sub,
+seal2 <- transform(seal.sub,
latr = cut(lat, 2),
longr = cut(long, 2))
View
@@ -26,6 +26,7 @@ if (require("maps")) {
ia <- map_data("county", "iowa")
mid_range <- function(x) mean(range(x))
+library(plyr)
seats <- ddply(ia, .(subregion), colwise(mid_range, .(lat, long)))
ggplot(ia, aes(long, lat)) +
geom_polygon(aes(group = group), fill = NA, colour = "grey60") +
View
@@ -26,7 +26,7 @@ library(reshape2)
library(plyr)
ecm <- melt(economics, id = "date")
rescale01 <- function(x) (x - min(x)) / diff(range(x))
-ecm <- ddply(ecm, "variable", mutate, value = rescale01(value))
+ecm <- ddply(ecm, "variable", transform, value = rescale01(value))
qplot(date, value, data=ecm, geom="line", group=variable)
qplot(date, value, data=ecm, geom="line", linetype=variable)

0 comments on commit d4845c8

Please sign in to comment.