Skip to content

Commit

Permalink
Namespace fixes for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Dec 29, 2011
1 parent 5010603 commit d4845c8
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions R/aes-colour-fill-alpha.r
Expand Up @@ -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")
Expand All @@ -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
2 changes: 1 addition & 1 deletion R/annotation-map.r
Expand Up @@ -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))
#'
Expand Down
1 change: 1 addition & 0 deletions R/fortify-map.r
Expand Up @@ -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") +
Expand Down
2 changes: 1 addition & 1 deletion R/scale-linetype.r
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions man/aes_colour_fill_alpha.Rd
Expand Up @@ -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")
Expand All @@ -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))
}

2 changes: 1 addition & 1 deletion man/annotation_map.Rd
Expand Up @@ -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))

Expand Down
1 change: 1 addition & 0 deletions man/borders.Rd
Expand Up @@ -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") +
Expand Down
2 changes: 1 addition & 1 deletion man/scale_linetype.Rd
Expand Up @@ -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)
Expand Down

0 comments on commit d4845c8

Please sign in to comment.