Permalink
Browse files

Roxygen 2.2

  • Loading branch information...
1 parent 0d6fd95 commit b4c112e3de8ca4f46630df54b6b5c8c088e0fdaa @hadley hadley committed Nov 30, 2011
Showing with 468 additions and 434 deletions.
  1. +4 −3 R/plot-construction.r
  2. +2 −2 man/absoluteGrob.Rd
  3. +2 −2 man/annotate.Rd
  4. +5 −4 man/continuous_scale.Rd
  5. +1 −1 man/coord_cartesian.Rd
  6. +2 −2 man/coord_map.Rd
  7. +11 −11 man/coord_polar.Rd
  8. +5 −5 man/coord_trans.Rd
  9. +0 −3 man/diamonds.Rd
  10. +4 −4 man/discrete_scale.Rd
  11. +0 −3 man/economics.Rd
  12. +2 −2 man/expand_limits.Rd
  13. +7 −7 man/facet_grid.Rd
  14. +6 −6 man/facet_wrap.Rd
  15. +14 −14 man/fortify.lm.Rd
  16. +1 −1 man/fortify.map.Rd
  17. +3 −3 man/geom_abline.Rd
  18. +1 −1 man/geom_area.Rd
  19. +5 −5 man/geom_bar.Rd
  20. +1 −1 man/geom_bin2d.Rd
  21. +2 −2 man/geom_blank.Rd
  22. +8 −7 man/geom_boxplot.Rd
  23. +4 −3 man/geom_contour.Rd
  24. +3 −2 man/geom_crossbar.Rd
  25. +3 −2 man/geom_density.Rd
  26. +4 −3 man/geom_density2d.Rd
  27. +6 −6 man/geom_errorbar.Rd
  28. +8 −8 man/geom_errorbarh.Rd
  29. +3 −3 man/geom_freqpoly.Rd
  30. +1 −1 man/geom_hex.Rd
  31. +7 −7 man/geom_histogram.Rd
  32. +1 −1 man/geom_hline.Rd
  33. +3 −2 man/geom_jitter.Rd
  34. +4 −4 man/geom_line.Rd
  35. +3 −3 man/geom_linerange.Rd
  36. +11 −11 man/geom_path.Rd
  37. +9 −8 man/geom_point.Rd
  38. +2 −2 man/geom_pointrange.Rd
  39. +11 −11 man/geom_polygon.Rd
  40. +4 −3 man/geom_quantile.Rd
  41. +3 −3 man/geom_rect.Rd
  42. +3 −2 man/geom_ribbon.Rd
  43. +1 −1 man/geom_rug.Rd
  44. +3 −3 man/geom_segment.Rd
  45. +4 −4 man/geom_smooth.Rd
  46. +3 −3 man/geom_step.Rd
  47. +4 −4 man/geom_text.Rd
  48. +10 −10 man/geom_tile.Rd
  49. +1 −1 man/geom_vline.Rd
  50. +2 −2 man/ggfluctuation.Rd
  51. +1 −1 man/ggmissing.Rd
  52. +8 −4 man/ggplot-add.Rd
  53. +1 −1 man/ggplot.data.frame.Rd
  54. +2 −1 man/ggplot2.Rd
  55. +3 −3 man/ggsave.Rd
  56. +1 −1 man/gtable.Rd
  57. +10 −8 man/guide_colorbar.Rd
  58. +11 −9 man/guide_legend.Rd
  59. +1 −1 man/label_parsed.Rd
  60. +3 −0 man/last_plot.Rd
  61. +2 −2 man/map_data.Rd
  62. +11 −14 man/midwest.Rd
  63. +10 −12 man/movies.Rd
  64. +3 −6 man/mpg.Rd
  65. +2 −5 man/msleep.Rd
  66. +1 −1 man/opts.Rd
  67. +4 −4 man/position_dodge.Rd
  68. +1 −1 man/position_fill.Rd
  69. +4 −4 man/position_stack.Rd
  70. +0 −3 man/presidential.Rd
  71. +2 −2 man/print.ggplot.Rd
  72. +9 −8 man/qplot.Rd
  73. +28 −0 man/scale_alpha.Rd
  74. +1 −1 man/scale_alpha_discrete.Rd
  75. +2 −2 man/scale_brewer.Rd
  76. +7 −7 man/scale_date.Rd
  77. +12 −12 man/scale_datetime.Rd
  78. +2 −2 man/scale_discrete.Rd
  79. +5 −5 man/scale_gradient.Rd
  80. +13 −14 man/scale_gradient2.Rd
  81. +5 −5 man/scale_grey.Rd
  82. +5 −4 man/scale_hue.Rd
  83. +11 −13 man/scale_identity.Rd
  84. +2 −2 man/scale_linetype.Rd
  85. +2 −2 man/scale_manual.Rd
  86. +0 −3 man/seals.Rd
  87. +1 −1 man/stat_abline.Rd
  88. +2 −2 man/stat_aggr2d.Rd
  89. +2 −2 man/stat_aggrhex.Rd
  90. +3 −3 man/stat_bin.Rd
  91. +3 −3 man/stat_bin2d.Rd
  92. +2 −2 man/stat_binhex.Rd
  93. +3 −3 man/stat_boxplot.Rd
  94. +3 −3 man/stat_contour.Rd
  95. +7 −7 man/stat_density.Rd
  96. +9 −9 man/stat_density2d.Rd
  97. +2 −1 man/stat_function.Rd
  98. +1 −1 man/stat_hline.Rd
  99. +2 −2 man/stat_identity.Rd
  100. +2 −2 man/stat_qq.Rd
  101. +5 −5 man/stat_quantile.Rd
  102. +7 −7 man/stat_smooth.Rd
  103. +1 −1 man/stat_spoke.Rd
  104. +1 −1 man/stat_sum.Rd
  105. +7 −7 man/stat_summary.Rd
  106. +1 −1 man/stat_unique.Rd
  107. +1 −1 man/stat_vline.Rd
  108. +3 −0 man/theme_blank.Rd
  109. +1 −1 man/theme_rect.Rd
  110. +2 −2 man/theme_text.Rd
  111. +2 −2 man/theme_update.Rd
  112. +3 −0 man/zeroGrob.Rd
View
@@ -17,10 +17,8 @@
#' @param object component to add
#' @seealso \code{\link{set_last_plot}}, \code{\link{ggplot}}
#' @method + ggplot
-#' @aliases +.ggplot \%+\%
#' @S3method "+" ggplot
-#' @export "%+%"
-#' @name ggplot-add
+#' @rdname ggplot-add
"+.ggplot" <- function(p, object) {
if (is.null(object)) return(p)
@@ -77,4 +75,7 @@
set_last_plot(p)
p
}
+
+#' @rdname ggplot-add
+#' @export
"%+%" <- `+.ggplot`
View
@@ -2,8 +2,8 @@
\alias{absoluteGrob}
\title{Absolute grob}
\usage{
- absoluteGrob(grob, width = NULL, height = NULL, xmin =
- NULL, ymin = NULL)
+ absoluteGrob(grob, width = NULL, height = NULL,
+ xmin = NULL, ymin = NULL)
}
\description{
This grob has fixed dimesions and position.
View
@@ -2,8 +2,8 @@
\alias{annotate}
\title{Annotate a plot}
\usage{
- annotate(geom, x = NULL, y = NULL, xmin = NULL, xmax =
- NULL, ymin = NULL, ymax = NULL, ...)
+ annotate(geom, x = NULL, y = NULL, xmin = NULL,
+ xmax = NULL, ymin = NULL, ymax = NULL, ...)
}
\arguments{
\item{name}{of geom to use for annotation}
View
@@ -2,10 +2,11 @@
\alias{continuous_scale}
\title{Continuous scale constructor.}
\usage{
- continuous_scale(aesthetics, scale_name, palette, name =
- NULL, breaks = NULL, minor_breaks = NULL, labels = NULL, legend = NULL, limits
- = NULL, rescaler = rescale, oob = censor, expand = c(0,
- 0), na.value = NA, trans = "identity", guide = "legend")
+ continuous_scale(aesthetics, scale_name, palette,
+ name = NULL, breaks = NULL, minor_breaks = NULL,
+ labels = NULL, legend = NULL, limits = NULL,
+ rescaler = rescale, oob = censor, expand = c(0, 0),
+ na.value = NA, trans = "identity", guide = "legend")
}
\arguments{
\item{aesthetics}{character}
View
@@ -39,7 +39,7 @@ p + coord_cartesian(xlim = c(325, 500))
# You can see the same thing with this 2d histogram
(d <- ggplot(diamonds, aes(carat, price)) +
-stat_bin2d(bins = 25, colour="grey50"))
+ stat_bin2d(bins = 25, colour="grey50"))
# When zooming the scale, the we get 25 new bins that are the same
# size on the plot, but represent smaller regions of the data space
View
@@ -2,8 +2,8 @@
\alias{coord_map}
\title{Map projections.}
\usage{
- coord_map(projection = "mercator", ..., orientation =
- NULL, xlim = NULL, ylim = NULL)
+ coord_map(projection = "mercator", ...,
+ orientation = NULL, xlim = NULL, ylim = NULL)
}
\arguments{
\item{projection}{projection to use, see
View
@@ -2,8 +2,8 @@
\alias{coord_polar}
\title{Polar coordinates.}
\usage{
- coord_polar(theta = "x", start = 0, direction = 1, expand
- = FALSE)
+ coord_polar(theta = "x", start = 0, direction = 1,
+ expand = FALSE)
}
\arguments{
\item{theta}{variable to map angle to (\code{x} or
@@ -15,7 +15,7 @@
\item{direction}{1, clockwise; -1, anticlockwise}
\item{should}{axes be expanded to slightly outside the
- range of the data? (default: FALSE)}
+ range of the data? (default: FALSE)}
}
\description{
The polar coordinate system is most commonly used for pie
@@ -30,29 +30,29 @@
# A coxcomb plot = bar chart + polar coordinates
cxc <- ggplot(mtcars, aes(x = factor(cyl))) +
-geom_bar(width = 1, colour = "black")
+ geom_bar(width = 1, colour = "black")
cxc + coord_polar()
# A new type of plot?
cxc + coord_polar(theta = "y")
# A pie chart = stacked bar chart + polar coordinates
pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
-geom_bar(width = 1)
+ geom_bar(width = 1)
pie + coord_polar(theta = "y")
# The bullseye chart
pie + coord_polar()
# Hadley's favourite pie chart
df <- data.frame(
-variable = c("resembles", "does not resemble"),
-value = c(80, 20)
+ variable = c("resembles", "does not resemble"),
+ value = c(80, 20)
)
ggplot(df, aes(x = "", y = value, fill = variable)) +
-geom_bar(width = 1) +
-scale_fill_manual(values = c("red", "yellow")) +
-coord_polar("y", start=pi / 3) +
-opts(title = "Pac man")
+ geom_bar(width = 1) +
+ scale_fill_manual(values = c("red", "yellow")) +
+ coord_polar("y", start=pi / 3) +
+ opts(title = "Pac man")
# Windrose + doughnut plot
movies$rrating <- cut_interval(movies$rating, length = 1)
View
@@ -32,10 +32,10 @@ qplot(carat, price, data=diamonds) + coord_trans(x = "log10", y = "log10")
d <- subset(diamonds, carat > 0.5)
qplot(carat, price, data = d, log="xy") +
-geom_smooth(method="lm")
+ geom_smooth(method="lm")
qplot(carat, price, data = d) +
-geom_smooth(method="lm") +
-coord_trans(x = "log10", y = "log10")
+ geom_smooth(method="lm") +
+ coord_trans(x = "log10", y = "log10")
# Here I used a subset of diamonds so that the smoothed line didn't
# drop below zero, which obviously causes problems on the log-transformed
@@ -45,8 +45,8 @@ coord_trans(x = "log10", y = "log10")
# possible to do back-transformations:
library(scales)
qplot(carat, price, data=diamonds, log="xy") +
-geom_smooth(method="lm") +
-coord_trans(x = exp_trans(10), y = exp_trans(10))
+ geom_smooth(method="lm") +
+ coord_trans(x = exp_trans(10), y = exp_trans(10))
# cf.
qplot(carat, price, data=diamonds) + geom_smooth(method = "lm")
View
@@ -3,9 +3,6 @@
\alias{diamonds}
\title{Prices of 50,000 round cut diamonds}
\format{A data frame with 53940 rows and 10 variables}
-\usage{
- data(diamonds)
-}
\description{
A dataset containing the prices and other attributes of
almost 54,000 diamonds. The variables are as follows:
View
@@ -2,10 +2,10 @@
\alias{discrete_scale}
\title{Discrete scale constructor.}
\usage{
- discrete_scale(aesthetics, scale_name, palette, name =
- NULL, breaks = NULL, labels = NULL, legend = NULL, limits
- = NULL, expand = c(0, 0), na.value = NA, drop = TRUE,
- guide = "legend")
+ discrete_scale(aesthetics, scale_name, palette,
+ name = NULL, breaks = NULL, labels = NULL,
+ legend = NULL, limits = NULL, expand = c(0, 0),
+ na.value = NA, drop = TRUE, guide = "legend")
}
\description{
Discrete scale constructor.
View
@@ -3,9 +3,6 @@
\alias{economics}
\title{US economic time series.}
\format{A data frame with 478 rows and 6 variables}
-\usage{
- data(economics)
-}
\description{
This dataset was produced from US economic time series
data available from
View
@@ -20,8 +20,8 @@ p + expand_limits(y = c(1, 9))
p + expand_limits(x = 0, y = 0)
qplot(mpg, wt, data = mtcars, colour = cyl) +
-expand_limits(colour = seq(2, 10, by = 2))
+ expand_limits(colour = seq(2, 10, by = 2))
qplot(mpg, wt, data = mtcars, colour = factor(cyl)) +
-expand_limits(colour = factor(seq(2, 10, by = 2)))
+ expand_limits(colour = factor(seq(2, 10, by = 2)))
}
View
@@ -3,8 +3,8 @@
\title{Lay out panels in a grid.}
\usage{
facet_grid(facets, margins = FALSE, scales = "fixed",
- space = "fixed", shrink = TRUE, labeller = "label_value",
- as.table = TRUE)
+ space = "fixed", shrink = TRUE,
+ labeller = "label_value", as.table = TRUE)
}
\arguments{
\item{facets}{a formula with the rows (of the tabular
@@ -23,7 +23,7 @@
\examples{
# faceting displays subsets of the data in different panels
p <- ggplot(diamonds, aes(carat, ..density..)) +
-geom_histogram(binwidth = 1)
+ geom_histogram(binwidth = 1)
# With one variable
p + facet_grid(. ~ cut)
@@ -87,17 +87,17 @@ mt + facet_grid(vs ~ am, scales = "free", space="free")
# You may need to set your own breaks for consitent display:
mt + facet_grid(. ~ cyl, scales = "free_x", space="free") +
-scale_x_continuous(breaks = seq(10, 36, by = 2))
+ scale_x_continuous(breaks = seq(10, 36, by = 2))
# Adding scale limits override free scales:
last_plot() + xlim(10, 15)
# Free scales are particularly useful for categorical variables
qplot(cty, model, data=mpg) +
-facet_grid(manufacturer ~ ., scales = "free", space = "free")
+ facet_grid(manufacturer ~ ., scales = "free", space = "free")
# particularly when you reorder factor levels
mpg <- within(mpg, {
-model <- reorder(model, cty)
-manufacturer <- reorder(manufacturer, cty)
+ model <- reorder(model, cty)
+ manufacturer <- reorder(manufacturer, cty)
})
last_plot() \%+\% mpg + opts(strip.text.y = theme_text())
View
@@ -2,8 +2,8 @@
\alias{facet_wrap}
\title{Wrap a 1d ribbon of panels into 2d.}
\usage{
- facet_wrap(facets, nrow = NULL, ncol = NULL, scales =
- "fixed", shrink = TRUE, as.table = TRUE)
+ facet_wrap(facets, nrow = NULL, ncol = NULL,
+ scales = "fixed", shrink = TRUE, as.table = TRUE)
}
\arguments{
\item{nrow}{number of rows}
@@ -20,7 +20,7 @@
}
\examples{
d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
-xlim(0, 2) + stat_binhex(na.rm = TRUE) + opts(aspect.ratio = 1)
+ xlim(0, 2) + stat_binhex(na.rm = TRUE) + opts(aspect.ratio = 1)
d + facet_wrap(~ color)
d + facet_wrap(~ color, ncol = 1)
d + facet_wrap(~ color, ncol = 4)
@@ -55,10 +55,10 @@ p + facet_wrap(~ cyl, as.table = F)
# Add data that does not contain all levels of the faceting variables
cyl6 <- subset(mpg, cyl == 6)
p + geom_point(data = cyl6, colour = "red", size = 1) +
-facet_wrap(~ cyl)
+ facet_wrap(~ cyl)
p + geom_point(data = transform(cyl6, cyl = 7), colour = "red") +
-facet_wrap(~ cyl)
+ facet_wrap(~ cyl)
p + geom_point(data = transform(cyl6, cyl = NULL), colour = "red") +
-facet_wrap(~ cyl)
+ facet_wrap(~ cyl)
}
View
@@ -36,13 +36,13 @@ head(fortify(mod, mtcars))
plot(mod, which = 1)
qplot(.fitted, .resid, data = mod) +
-geom_hline(yintercept = 0) +
-geom_smooth(se = FALSE)
+ geom_hline(yintercept = 0) +
+ geom_smooth(se = FALSE)
qplot(.fitted, .stdresid, data = mod) +
-geom_hline(yintercept = 0) +
-geom_smooth(se = FALSE)
+ geom_hline(yintercept = 0) +
+ geom_smooth(se = FALSE)
qplot(.fitted, .stdresid, data = fortify(mod, mtcars),
-colour = factor(cyl))
+ colour = factor(cyl))
qplot(mpg, .stdresid, data = fortify(mod, mtcars), colour = factor(cyl))
plot(mod, which = 2)
@@ -53,24 +53,24 @@ qplot(.fitted, sqrt(abs(.stdresid)), data = mod) + geom_smooth(se = FALSE)
plot(mod, which = 4)
qplot(seq_along(.cooksd), .cooksd, data = mod, geom = "bar",
-stat="identity")
+ stat="identity")
plot(mod, which = 5)
qplot(.hat, .stdresid, data = mod) + geom_smooth(se = FALSE)
ggplot(mod, aes(.hat, .stdresid)) +
-geom_vline(size = 2, colour = "white", xintercept = 0) +
-geom_hline(size = 2, colour = "white", yintercept = 0) +
-geom_point() + geom_smooth(se = FALSE)
+ geom_vline(size = 2, colour = "white", xintercept = 0) +
+ geom_hline(size = 2, colour = "white", yintercept = 0) +
+ geom_point() + geom_smooth(se = FALSE)
qplot(.hat, .stdresid, data = mod, size = .cooksd) +
-geom_smooth(se = FALSE, size = 0.5)
+ geom_smooth(se = FALSE, size = 0.5)
plot(mod, which = 6)
ggplot(mod, aes(.hat, .cooksd)) +
-geom_vline(xintercept = 0, colour = NA) +
-geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") +
-geom_smooth(se = FALSE) +
-geom_point()
+ geom_vline(xintercept = 0, colour = NA) +
+ geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") +
+ geom_smooth(se = FALSE) +
+ geom_point()
qplot(.hat, .cooksd, size = .cooksd / .hat, data = mod) + scale_area()
}
View
@@ -24,7 +24,7 @@ qplot(long, lat, data = ca, geom = "polygon", group = group)
tx <- map("county", "texas", plot = FALSE, fill = TRUE)
head(fortify(tx))
qplot(long, lat, data = tx, geom = "polygon", group = group,
-colour = I("white"))
+ colour = I("white"))
}
}
\seealso{
View
@@ -3,7 +3,7 @@
\title{Line specified by slope and intercept.}
\usage{
geom_abline(mapping = NULL, data = NULL, stat = "abline",
- position = "identity", ...)
+ position = "identity", ...)
}
\description{
The abline geom adds a line with specified slope and
@@ -43,8 +43,8 @@ p + geom_abline(aes(intercept=a, slope=b), data=df)
# Slopes and intercepts from linear model
library(plyr)
coefs <- ddply(mtcars, .(cyl), function(df) {
-m <- lm(mpg ~ wt, data=df)
-data.frame(a = coef(m)[1], b = coef(m)[2])
+ m <- lm(mpg ~ wt, data=df)
+ data.frame(a = coef(m)[1], b = coef(m)[2])
})
str(coefs)
p + geom_abline(data=coefs, aes(intercept=a, slope=b))
View
@@ -3,7 +3,7 @@
\title{Area plot.}
\usage{
geom_area(mapping = NULL, data = NULL, stat = "identity",
- position = "stack", na.rm = FALSE, ...)
+ position = "stack", na.rm = FALSE, ...)
}
\description{
An area plot is the continuous analog of a stacked bar
Oops, something went wrong.

0 comments on commit b4c112e

Please sign in to comment.