Skip to content

Commit 17b45f9

Browse files
author
Dana Paige Seidel
authored
Minor documentation edits (#2727)
1 parent 9b640c5 commit 17b45f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+350
-356
lines changed

R/aes.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ NULL
99
#'
1010
#' This function also standardises aesthetic names by performing partial
1111
#' matching, converting color to colour, and translating old style R names to
12-
#' ggplot names (eg. pch to shape, cex to size).
12+
#' ggplot names (e.g. pch to shape, cex to size).
1313
#'
1414
#' @section Quasiquotation:
1515
#'
@@ -165,7 +165,7 @@ is_position_aes <- function(vars) {
165165
aes_to_scale(vars) %in% c("x", "y")
166166
}
167167

168-
#' Define aesthetic mappings programatically
168+
#' Define aesthetic mappings programmatically
169169
#'
170170
#' Aesthetic mappings describe how variables in the data are mapped to visual
171171
#' properties (aesthetics) of geoms. [aes()] uses non-standard

R/facet-.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ NULL
6666
#'
6767
#' - `draw_labels`: Given the gtable returned by `draw_panels`,
6868
#' add axis titles to the gtable. The default is to add one title at each side
69-
#' depending on the position and existance of axes.
69+
#' depending on the position and existence of axes.
7070
#'
71-
#' All extension methods recieve the content of the params field as the params
71+
#' All extension methods receive the content of the params field as the params
7272
#' argument, so the constructor function will generally put all relevant
7373
#' information into this field. The only exception is the `shrink`
7474
#' parameter which is used to determine if scales are retrained after Stat

R/facet-grid-.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ NULL
103103
#'
104104
#' # Margins ----------------------------------------------------------
105105
#' \donttest{
106-
#' # Margins can be specified by logically (all yes or all no) or by specific
106+
#' # Margins can be specified logically (all yes or all no) or for specific
107107
#' # variables as (character) variable names
108108
#' mg <- ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point()
109109
#' mg + facet_grid(vs + am ~ gear, margins = TRUE)

R/fortify-map.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ map_data <- function(map, region = ".", exact = FALSE, ...) {
8585
#' @param regions map region
8686
#' @param fill fill colour
8787
#' @param colour border colour
88-
#' @param xlim,ylim latitudinal and logitudinal range for extracting map
88+
#' @param xlim,ylim latitudinal and longitudinal ranges for extracting map
8989
#' polygons, see [maps::map()] for details.
9090
#' @inheritDotParams geom_polygon
9191
#' @export

R/geom-bar.r

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#' Bar charts
22
#'
3-
#' There are two types of bar charts: `geom_bar` makes the height of the
3+
#' There are two types of bar charts: `geom_bar()` and `geom_col()`.
4+
#' `geom_bar()` makes the height of the
45
#' bar proportional to the number of cases in each group (or if the
56
#' `weight` aesthetic is supplied, the sum of the weights). If you want the
67
#' heights of the bars to represent values in the data, use
7-
#' \link{geom_col} instead. `geom_bar` uses `stat_count` by
8-
#' default: it counts the number of cases at each x position. `geom_col`
9-
#' uses `stat_identity`: it leaves the data as is.
8+
#' `geom_col()` instead. `geom_bar()` uses `stat_count()` by
9+
#' default: it counts the number of cases at each x position. `geom_col()`
10+
#' uses `stat_identity()`: it leaves the data as is.
1011
#'
1112
#' A bar chart uses height to represent a value, and so the base of the
1213
#' bar must always be shown to produce a valid visual comparison. Naomi Robbins
@@ -25,16 +26,16 @@
2526
#' @seealso
2627
#' [geom_histogram()] for continuous data,
2728
#' [position_dodge()] and [position_dodge2()] for creating side-by-side
28-
#' barcharts.
29+
#' bar charts.
2930
#' @export
3031
#' @inheritParams layer
3132
#' @inheritParams geom_point
3233
#' @param width Bar width. By default, set to 90\% of the resolution of the data.
33-
#' @param binwidth `geom_bar` no longer has a binwidth argument - if
34+
#' @param binwidth `geom_bar()` no longer has a binwidth argument - if
3435
#' you use it you'll get an warning telling to you use
3536
#' [geom_histogram()] instead.
36-
#' @param geom,stat Override the default connection between `geom_bar` and
37-
#' `stat_count`.
37+
#' @param geom,stat Override the default connection between `geom_bar()` and
38+
#' `stat_count()`.
3839
#' @examples
3940
#' # geom_bar is designed to make it easy to create bar charts that show
4041
#' # counts (or sums of weights)

R/geom-boxplot.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#' if the notches of two boxes do not overlap, this suggests that the medians
5050
#' are significantly different.
5151
#' @param notchwidth For a notched box plot, width of the notch relative to
52-
#' the body (default 0.5)
52+
#' the body (defaults to `notchwidth = 0.5`).
5353
#' @param varwidth If `FALSE` (default) make a standard box plot. If
5454
#' `TRUE`, boxes are drawn with widths proportional to the
5555
#' square-roots of the number of observations in the groups (possibly

R/geom-linerange.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#' `geom_pointrange()`.
1010
#' @seealso
1111
#' [stat_summary()] for examples of these guys in use,
12-
#' [geom_smooth()] for continuous analog,
12+
#' [geom_smooth()] for continuous analogue,
1313
#' [geom_errorbarh()] for a horizontal error bar.
1414
#' @export
1515
#' @inheritParams layer

R/geom-point.r

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#' There is no one solution to this problem, but there are some techniques
1919
#' that can help. You can add additional information with
2020
#' [geom_smooth()], [geom_quantile()] or
21-
#' [geom_density_2d()]. If you have few unique x values,
21+
#' [geom_density_2d()]. If you have few unique `x` values,
2222
#' [geom_boxplot()] may also be useful.
2323
#'
2424
#' Alternatively, you can
@@ -36,7 +36,7 @@
3636
#' a warning. If `TRUE`, missing values are silently removed.
3737
#' @param ... Other arguments passed on to [layer()]. These are
3838
#' often aesthetics, used to set an aesthetic to a fixed value, like
39-
#' `color = "red"` or `size = 3`. They may also be parameters
39+
#' `colour = "red"` or `size = 3`. They may also be parameters
4040
#' to the paired geom/stat.
4141
#' @inheritParams layer
4242
#' @export
@@ -76,12 +76,6 @@
7676
#' geom_point(colour = "pink", size = 4) +
7777
#' geom_point(aes(shape = factor(cyl)))
7878
#'
79-
#' # These extra layers don't usually appear in the legend, but we can
80-
#' # force their inclusion
81-
#' p + geom_point(colour = "black", size = 4.5, show.legend = TRUE) +
82-
#' geom_point(colour = "pink", size = 4, show.legend = TRUE) +
83-
#' geom_point(aes(shape = factor(cyl)))
84-
#'
8579
#' # geom_point warns when missing values have been dropped from the data set
8680
#' # and not plotted, you can turn this off by setting na.rm = TRUE
8781
#' mtcars2 <- transform(mtcars, mpg = ifelse(runif(32) < 0.2, NA, mpg))

R/geom-ribbon.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' by `ymin` and `ymax`. `geom_area` is a special case of
55
#' `geom_ribbon`, where the `ymin` is fixed to 0.
66
#'
7-
#' An area plot is the continuous analog of a stacked bar chart (see
7+
#' An area plot is the continuous analogue of a stacked bar chart (see
88
#' [geom_bar()]), and can be used to show how composition of the
99
#' whole varies over the range of x. Choosing the order in which different
1010
#' components is stacked is very important, as it becomes increasing hard to

R/geom-segment.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#' @inheritParams layer
1313
#' @inheritParams geom_point
1414
#' @param arrow specification for arrow heads, as created by arrow().
15-
#' @param arrow.fill fill color to use for the arrow head (if closed). `NULL`
15+
#' @param arrow.fill fill colour to use for the arrow head (if closed). `NULL`
1616
#' means use `colour` aesthetic.
1717
#' @param lineend Line end style (round, butt, square).
1818
#' @param linejoin Line join style (round, mitre, bevel).

R/geom-smooth.r

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#'
88
#' Calculation is performed by the (currently undocumented)
99
#' `predictdf` generic and its methods. For most methods the standard
10-
#' error bounds are computed using the [predict()] method - the
11-
#' exceptions are `loess` which uses a t-based approximation, and
12-
#' `glm` where the normal confidence interval is constructed on the link
13-
#' scale, and then back-transformed to the response scale.
10+
#' error bounds are computed using the [predict()] method -- the
11+
#' exceptions are `loess`, which uses a t-based approximation, and
12+
#' `glm`, where the normal confidence interval is constructed on the link
13+
#' scale and then back-transformed to the response scale.
1414
#'
1515
#' @eval rd_aesthetics("geom", "smooth")
1616
#' @inheritParams layer
@@ -19,15 +19,15 @@
1919
#' `geom_smooth` and `stat_smooth`.
2020
#' @seealso See individual modelling functions for more details:
2121
#' [lm()] for linear smooths,
22-
#' [glm()] for generalised linear smooths,
23-
#' [loess()] for local smooths
22+
#' [glm()] for generalised linear smooths, and
23+
#' [loess()] for local smooths.
2424
#' @export
2525
#' @examples
2626
#' ggplot(mpg, aes(displ, hwy)) +
2727
#' geom_point() +
2828
#' geom_smooth()
2929
#'
30-
#' # Use span to control the "wiggliness" of the default loess smoother
30+
#' # Use span to control the "wiggliness" of the default loess smoother.
3131
#' # The span is the fraction of points used to fit each local regression:
3232
#' # small numbers make a wigglier curve, larger numbers make a smoother curve.
3333
#' ggplot(mpg, aes(displ, hwy)) +
@@ -43,8 +43,8 @@
4343
#' geom_point() +
4444
#' geom_smooth(method = lm, formula = y ~ splines::bs(x, 3), se = FALSE)
4545
#'
46-
#' # Smoothes are automatically fit to each group (defined by categorical
47-
#' # aesthetics or the group aesthetic) and for each facet
46+
#' # Smooths are automatically fit to each group (defined by categorical
47+
#' # aesthetics or the group aesthetic) and for each facet.
4848
#'
4949
#' ggplot(mpg, aes(displ, hwy, colour = class)) +
5050
#' geom_point() +
@@ -73,7 +73,7 @@
7373
#' binomial_smooth(formula = y ~ splines::ns(x, 2))
7474
#'
7575
#' # But in this case, it's probably better to fit the model yourself
76-
#' # so you can exercise more control and see whether or not it's a good model
76+
#' # so you can exercise more control and see whether or not it's a good model.
7777
#' }
7878
geom_smooth <- function(mapping = NULL, data = NULL,
7979
stat = "smooth", position = "identity",

R/geom-text.r

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#' data, even if coordinates x, y are set to single values in the call
1515
#' to `geom_label` or `geom_text`.
1616
#' To add labels at specified points use [annotate()] with
17-
#' `annotate(geom = "text", ...)` or `annotate(geom = "label", ...)`
17+
#' `annotate(geom = "text", ...)` or `annotate(geom = "label", ...)`.
1818
#'
1919
#' @eval rd_aesthetics("geom", "text")
2020
#' @section `geom_label`:
@@ -28,12 +28,12 @@
2828
#' 1 (top/left) or a character (`"left"`, `"middle"`, `"right"`, `"bottom"`,
2929
#' `"center"`, `"top"`). There are two special alignments: `"inward"` and
3030
#' `"outward"`. Inward always aligns text towards the center, and outward
31-
#' aligns it away from the center
31+
#' aligns it away from the center.
3232
#'
3333
#' @inheritParams layer
3434
#' @inheritParams geom_point
3535
#' @param parse If `TRUE`, the labels will be parsed into expressions and
36-
#' displayed as described in ?plotmath
36+
#' displayed as described in `?plotmath`.
3737
#' @param nudge_x,nudge_y Horizontal and vertical adjustment to nudge labels by.
3838
#' Useful for offsetting text from points, particularly on discrete scales.
3939
#' @param check_overlap If `TRUE`, text that overlaps previous text in the
@@ -97,7 +97,7 @@
9797
#' ggplot(data = df, aes(x, y, group = grp)) +
9898
#' geom_col(aes(fill = grp), position = "dodge") +
9999
#' geom_text(aes(label = y), position = position_dodge(0.9))
100-
#' # Use you can't nudge and dodge text, so instead adjust the y postion
100+
#' # Use you can't nudge and dodge text, so instead adjust the y position
101101
#' ggplot(data = df, aes(x, y, group = grp)) +
102102
#' geom_col(aes(fill = grp), position = "dodge") +
103103
#' geom_text(

R/guide-colorbar.r

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
#' Continuous colour bar guide
22
#'
3-
#' Colour bar guide shows continuous color scales mapped onto values.
3+
#' Colour bar guide shows continuous colour scales mapped onto values.
44
#' Colour bar is available with `scale_fill` and `scale_colour`.
55
#' For more information, see the inspiration for this function:
66
#' \href{http://www.mathworks.com/help/techdoc/ref/colorbar.html}{Matlab's colorbar function}.
77
#'
88
#' Guides can be specified in each `scale_*` or in [guides()].
99
#' `guide="legend"` in `scale_*` is syntactic sugar for
10-
#' `guide=guide_legend()` (e.g. `scale_color_manual(guide = "legend")`).
10+
#' `guide=guide_legend()` (e.g. `scale_colour_manual(guide = "legend")`).
1111
#' As for how to specify the guide for each scale in more detail,
1212
#' see [guides()].
1313
#'
1414
#' @inheritParams guide_legend
1515
#' @param barwidth A numeric or a [grid::unit()] object specifying
16-
#' the width of the colorbar. Default value is `legend.key.width` or
16+
#' the width of the colourbar. Default value is `legend.key.width` or
1717
#' `legend.key.size` in [theme()] or theme.
1818
#' @param barheight A numeric or a [grid::unit()] object specifying
19-
#' the height of the colorbar. Default value is `legend.key.height` or
19+
#' the height of the colourbar. Default value is `legend.key.height` or
2020
#' `legend.key.size` in [theme()] or theme.
2121
#' @param frame.colour A string specifying the colour of the frame
2222
#' drawn around the bar. If `NULL` (the default), no frame is drawn.
2323
#' @param frame.linewidth A numeric specifying the width of the frame
2424
#' drawn around the bar.
2525
#' @param frame.linetype A numeric specifying the linetype of the frame
2626
#' drawn around the bar.
27-
#' @param nbin A numeric specifying the number of bins for drawing colorbar. A
28-
#' smoother colorbar for a larger value.
29-
#' @param raster A logical. If `TRUE` then the colorbar is rendered as a
30-
#' raster object. If `FALSE` then the colorbar is rendered as a set of
27+
#' @param nbin A numeric specifying the number of bins for drawing the
28+
#' colourbar. A smoother colourbar results from a larger value.
29+
#' @param raster A logical. If `TRUE` then the colourbar is rendered as a
30+
#' raster object. If `FALSE` then the colourbar is rendered as a set of
3131
#' rectangles. Note that not all graphics devices are capable of rendering
3232
#' raster image.
33-
#' @param ticks A logical specifying if tick marks on colorbar should be
33+
#' @param ticks A logical specifying if tick marks on the colourbar should be
3434
#' visible.
35-
#' @param ticks.colour A string specifying the color of the tick marks.
35+
#' @param ticks.colour A string specifying the colour of the tick marks.
3636
#' @param ticks.linewidth A numeric specifying the width of the tick marks.
3737
#' @param draw.ulim A logical specifying if the upper limit tick marks should
3838
#' be visible.
@@ -42,10 +42,10 @@
4242
#' One of "horizontal" or "vertical."
4343
#' @param default.unit A character string indicating [grid::unit()]
4444
#' for `barwidth` and `barheight`.
45-
#' @param reverse logical. If `TRUE` the colorbar is reversed. By default,
45+
#' @param reverse logical. If `TRUE` the colourbar is reversed. By default,
4646
#' the highest value is on the top and the lowest value is on the bottom
47-
#' @param available_aes A vector of charater strings listing the aesthetics
48-
#' for which a colorbar can be drawn.
47+
#' @param available_aes A vector of character strings listing the aesthetics
48+
#' for which a colourbar can be drawn.
4949
#' @param ... ignored.
5050
#' @return A guide object
5151
#' @export
@@ -57,45 +57,45 @@
5757
#' p2 <- p1 + geom_point(aes(size = value))
5858
#'
5959
#' # Basic form
60-
#' p1 + scale_fill_continuous(guide = "colorbar")
61-
#' p1 + scale_fill_continuous(guide = guide_colorbar())
62-
#' p1 + guides(fill = guide_colorbar())
60+
#' p1 + scale_fill_continuous(guide = "colourbar")
61+
#' p1 + scale_fill_continuous(guide = guide_colourbar())
62+
#' p1 + guides(fill = guide_colourbar())
6363
#'
6464
#' # Control styles
6565
#'
6666
#' # bar size
67-
#' p1 + guides(fill = guide_colorbar(barwidth = 0.5, barheight = 10))
67+
#' p1 + guides(fill = guide_colourbar(barwidth = 0.5, barheight = 10))
6868
#'
6969
#' # no label
70-
#' p1 + guides(fill = guide_colorbar(label = FALSE))
70+
#' p1 + guides(fill = guide_colourbar(label = FALSE))
7171
#'
7272
#' # no tick marks
73-
#' p1 + guides(fill = guide_colorbar(ticks = FALSE))
73+
#' p1 + guides(fill = guide_colourbar(ticks = FALSE))
7474
#'
7575
#' # label position
76-
#' p1 + guides(fill = guide_colorbar(label.position = "left"))
76+
#' p1 + guides(fill = guide_colourbar(label.position = "left"))
7777
#'
7878
#' # label theme
79-
#' p1 + guides(fill = guide_colorbar(label.theme = element_text(colour = "blue", angle = 0)))
79+
#' p1 + guides(fill = guide_colourbar(label.theme = element_text(colour = "blue", angle = 0)))
8080
#'
8181
#' # small number of bins
82-
#' p1 + guides(fill = guide_colorbar(nbin = 3))
82+
#' p1 + guides(fill = guide_colourbar(nbin = 3))
8383
#'
8484
#' # large number of bins
85-
#' p1 + guides(fill = guide_colorbar(nbin = 100))
85+
#' p1 + guides(fill = guide_colourbar(nbin = 100))
8686
#'
8787
#' # make top- and bottom-most ticks invisible
8888
#' p1 + scale_fill_continuous(limits = c(0,20), breaks = c(0, 5, 10, 15, 20),
89-
#' guide = guide_colorbar(nbin=100, draw.ulim = FALSE, draw.llim = FALSE))
89+
#' guide = guide_colourbar(nbin=100, draw.ulim = FALSE, draw.llim = FALSE))
9090
#'
9191
#' # guides can be controlled independently
9292
#' p2 +
93-
#' scale_fill_continuous(guide = "colorbar") +
93+
#' scale_fill_continuous(guide = "colourbar") +
9494
#' scale_size(guide = "legend")
95-
#' p2 + guides(fill = "colorbar", size = "legend")
95+
#' p2 + guides(fill = "colourbar", size = "legend")
9696
#'
9797
#' p2 +
98-
#' scale_fill_continuous(guide = guide_colorbar(direction = "horizontal")) +
98+
#' scale_fill_continuous(guide = guide_colourbar(direction = "horizontal")) +
9999
#' scale_size(guide = guide_legend(direction = "vertical"))
100100
guide_colourbar <- function(
101101

@@ -195,12 +195,12 @@ guide_train.colorbar <- function(guide, scale, aesthetic = NULL) {
195195

196196
# do nothing if scale are inappropriate
197197
if (length(intersect(scale$aesthetics, guide$available_aes)) == 0) {
198-
warning("colorbar guide needs appropriate scales: ",
198+
warning("colourbar guide needs appropriate scales: ",
199199
paste(guide$available_aes, collapse = ", "))
200200
return(NULL)
201201
}
202202
if (scale$is_discrete()) {
203-
warning("colorbar guide needs continuous scales.")
203+
warning("colourbar guide needs continuous scales.")
204204
return(NULL)
205205
}
206206

0 commit comments

Comments
 (0)