Skip to content
Browse files

Checking examples. Up to geom_blank.Rd

  • Loading branch information...
1 parent ce66730 commit 3d8b389356f51f6d509d57741b8ad030e7ee706d @hadley committed Dec 29, 2011
Showing with 32 additions and 20 deletions.
  1. +11 −6 R/aes-linetype-size-shape.r
  2. +2 −2 R/facet-grid-.r
  3. +1 −0 R/geom-boxplot.r
  4. +2 −2 R/quick-plot.r
  5. +11 −6 man/aes_linetype_size_shape.Rd
  6. +2 −2 man/facet_grid.Rd
  7. +1 −0 man/geom_boxplot.Rd
  8. +2 −2 man/qplot.Rd
View
17 R/aes-linetype-size-shape.r
@@ -24,7 +24,12 @@
#' f + geom_line(linetype = "3313")
#'
#' # Mapping line type from a variable
-#' ec_scaled <- data.frame(date = economics$date, rescaler(economics[, -(1:2)], "range"))
+#' library(plyr)
+#' library(reshape2)
+#' rescale01 <- function(x) (x - min(x)) / diff(range(x))
+#' ec_scaled <- data.frame(
+#' date = economics$date,
+#' colwise(rescale01)(economics[, -(1:2)]))
#' ecm <- melt(ec_scaled, id = "date")
#' qplot(date, value, data = ecm, geom = "line", linetype = variable)
#'
@@ -49,15 +54,15 @@
#'
#' # Shape can also be mapped from a variable
#' p + geom_point(aes(shape = factor(cyl)))
-#' # Compare to this plot which uses the values of cyl
-#' p + geom_point(aes(shape = cyl))
#'
#' # A look at all 25 symbols
#' df2 <- data.frame(x = 1:5 , y = 1:25, z = 1:25)
#' s <- ggplot(df2, aes(x = x, y = y))
-#' s + geom_point(aes(shape = z), size = 4)
+#' s + geom_point(aes(shape = z), size = 4) + scale_shape_identity()
#' # While all symbols have a foreground colour, symbols 19-25 also take a
#' # background colour (fill)
-#' s + geom_point(aes(shape = z), size = 4, colour = "Red")
-#' s + geom_point(aes(shape = z), size = 4, colour = "Red", fill = "Black")
+#' s + geom_point(aes(shape = z), size = 4, colour = "Red") +
+#' scale_shape_identity()
+#' s + geom_point(aes(shape = z), size = 4, colour = "Red", fill = "Black") +
+#' scale_shape_identity()
NULL
View
4 R/facet-grid-.r
@@ -125,8 +125,8 @@
#' k + facet_grid(. ~ cyl2, labeller = label_parsed)
#' # For label_bquote the label value is x.
#' p <- qplot(wt, mpg, data = mtcars)
-#' p + facet_grid(~ vs, labeller = label_bquote(alpha ^ .(x)))
-#' p + facet_grid(~ vs, labeller = label_bquote(.(x) ^ .(x)))
+#' p + facet_grid(. ~ vs, labeller = label_bquote(alpha ^ .(x)))
+#' p + facet_grid(. ~ vs, labeller = label_bquote(.(x) ^ .(x)))
facet_grid <- function(facets, margins = FALSE, scales = "fixed", space = "fixed", shrink = TRUE, labeller = "label_value", as.table = TRUE, drop = TRUE) {
scales <- match.arg(scales, c("fixed", "free_x", "free_y", "free"))
free <- list(
View
1 R/geom-boxplot.r
@@ -62,6 +62,7 @@
#' # Scale transformations occur before the boxplot statistics are computed.
#' # Coordinate transformations occur afterwards. Observe the effect on the
#' # number of outliers.
+#' library(plyr) # to access round_any
#' m <- ggplot(movies, aes(y = votes, x = rating,
#' group = round_any(rating, 0.5)))
#' m + geom_boxplot()
View
4 R/quick-plot.r
@@ -61,8 +61,8 @@
#' qplot(y = mpg, data = mtcars)
#'
#' # Use different geoms
-#' qplot(mpg, wt, geom="path")
-#' qplot(factor(cyl), wt, geom=c("boxplot", "jitter"))
+#' qplot(mpg, wt, data = mtcars, geom="path")
+#' qplot(factor(cyl), wt, data = mtcars, geom=c("boxplot", "jitter"))
qplot <- function(x, y = NULL, ..., data, facets = NULL, margins=FALSE, geom = "auto", stat=list(NULL), position=list(NULL), xlim = c(NA, NA), ylim = c(NA, NA), log = "", main = NULL, xlab = deparse(substitute(x)), ylab = deparse(substitute(y)), asp = NA) {
argnames <- names(as.list(match.call(expand.dots=FALSE)[-1]))
View
17 man/aes_linetype_size_shape.Rd
@@ -25,7 +25,12 @@ f + geom_line(linetype = "dotdash")
f + geom_line(linetype = "3313")
# Mapping line type from a variable
-ec_scaled <- data.frame(date = economics$date, rescaler(economics[, -(1:2)], "range"))
+library(plyr)
+library(reshape2)
+rescale01 <- function(x) (x - min(x)) / diff(range(x))
+ec_scaled <- data.frame(
+ date = economics$date,
+ colwise(rescale01)(economics[, -(1:2)]))
ecm <- melt(ec_scaled, id = "date")
qplot(date, value, data = ecm, geom = "line", linetype = variable)
@@ -50,16 +55,16 @@ p + geom_point(shape = NA)
# Shape can also be mapped from a variable
p + geom_point(aes(shape = factor(cyl)))
-# Compare to this plot which uses the values of cyl
-p + geom_point(aes(shape = cyl))
# A look at all 25 symbols
df2 <- data.frame(x = 1:5 , y = 1:25, z = 1:25)
s <- ggplot(df2, aes(x = x, y = y))
-s + geom_point(aes(shape = z), size = 4)
+s + geom_point(aes(shape = z), size = 4) + scale_shape_identity()
# While all symbols have a foreground colour, symbols 19-25 also take a
# background colour (fill)
-s + geom_point(aes(shape = z), size = 4, colour = "Red")
-s + geom_point(aes(shape = z), size = 4, colour = "Red", fill = "Black")
+s + geom_point(aes(shape = z), size = 4, colour = "Red") +
+ scale_shape_identity()
+s + geom_point(aes(shape = z), size = 4, colour = "Red", fill = "Black") +
+ scale_shape_identity()
}
View
4 man/facet_grid.Rd
@@ -151,7 +151,7 @@ k + facet_grid(. ~ cyl2)
k + facet_grid(. ~ cyl2, labeller = label_parsed)
# For label_bquote the label value is x.
p <- qplot(wt, mpg, data = mtcars)
-p + facet_grid(~ vs, labeller = label_bquote(alpha ^ .(x)))
-p + facet_grid(~ vs, labeller = label_bquote(.(x) ^ .(x)))
+p + facet_grid(. ~ vs, labeller = label_bquote(alpha ^ .(x)))
+p + facet_grid(. ~ vs, labeller = label_bquote(.(x) ^ .(x)))
}
View
1 man/geom_boxplot.Rd
@@ -91,6 +91,7 @@ qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot",
# Scale transformations occur before the boxplot statistics are computed.
# Coordinate transformations occur afterwards. Observe the effect on the
# number of outliers.
+library(plyr) # to access round_any
m <- ggplot(movies, aes(y = votes, x = rating,
group = round_any(rating, 0.5)))
m + geom_boxplot()
View
4 man/qplot.Rd
@@ -96,7 +96,7 @@ qplot(mpg, data = mtcars)
qplot(y = mpg, data = mtcars)
# Use different geoms
-qplot(mpg, wt, geom="path")
-qplot(factor(cyl), wt, geom=c("boxplot", "jitter"))
+qplot(mpg, wt, data = mtcars, geom="path")
+qplot(factor(cyl), wt, data = mtcars, geom=c("boxplot", "jitter"))
}

0 comments on commit 3d8b389

Please sign in to comment.
Something went wrong with that request. Please try again.