Skip to content

Commit 344bfea

Browse files
author
Dana Paige Seidel
authored
Minor Documentation Fixes (#2768)
* A second round of minor doc fixes throughout stack * Clarify geom_boxplot examples Closes #2793
1 parent f135340 commit 344bfea

Some content is hidden

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

79 files changed

+341
-316
lines changed

R/facet-grid-.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ NULL
33

44
#' Lay out panels in a grid
55
#'
6-
#' `facet_grid` forms a matrix of panels defined by row and column
6+
#' `facet_grid()` forms a matrix of panels defined by row and column
77
#' faceting variables. It is most useful when you have two discrete
88
#' variables, and all combinations of the variables exist in the data.
99
#'

R/geom-abline.r

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ NULL
2525
#' `size`. They also each have aesthetics that control the position of
2626
#' the line:
2727
#'
28-
#' - `geom_vline`: `xintercept`
29-
#' - `geom_hline`: `yintercept`
30-
#' - `geom_abline`: `slope` and `intercept`
28+
#' - `geom_vline()`: `xintercept`
29+
#' - `geom_hline()`: `yintercept`
30+
#' - `geom_abline()`: `slope` and `intercept`
3131
#'
3232
#' @seealso See [geom_segment()] for a more general approach to
3333
#' adding straight line segments to a plot.

R/geom-boxplot.r

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#' @section Summary statistics:
88
#' The lower and upper hinges correspond to the first and third quartiles
99
#' (the 25th and 75th percentiles). This differs slightly from the method used
10-
#' by the `boxplot` function, and may be apparent with small samples.
10+
#' by the [boxplot()] function, and may be apparent with small samples.
1111
#' See [boxplot.stats()] for for more information on how hinge
12-
#' positions are calculated for `boxplot`.
12+
#' positions are calculated for [boxplot()].
1313
#'
1414
#' The upper whisker extends from the hinge to the largest value no further than
1515
#' 1.5 * IQR from the hinge (where IQR is the inter-quartile range, or distance
@@ -24,7 +24,7 @@
2424
#'
2525
#' @eval rd_aesthetics("geom", "boxplot")
2626
#'
27-
#' @seealso [geom_quantile()] for continuous x,
27+
#' @seealso [geom_quantile()] for continuous `x`,
2828
#' [geom_violin()] for a richer display of the distribution, and
2929
#' [geom_jitter()] for a useful technique for small data.
3030
#' @inheritParams layer
@@ -60,7 +60,6 @@
6060
#' @examples
6161
#' p <- ggplot(mpg, aes(class, hwy))
6262
#' p + geom_boxplot()
63-
#' p + geom_boxplot() + geom_jitter(width = 0.2)
6463
#' p + geom_boxplot() + coord_flip()
6564
#'
6665
#' p + geom_boxplot(notch = TRUE)
@@ -69,6 +68,8 @@
6968
#' # By default, outlier points match the colour of the box. Use
7069
#' # outlier.colour to override
7170
#' p + geom_boxplot(outlier.colour = "red", outlier.shape = 1)
71+
#' # Remove outliers when overlaying boxplot with original data points
72+
#' p + geom_boxplot(outlier.shape = NA) + geom_jitter(width = 0.2)
7273
#'
7374
#' # Boxplots are automatically dodged when any aesthetic is a factor
7475
#' p + geom_boxplot(aes(colour = drv))
@@ -79,6 +80,7 @@
7980
#' geom_boxplot()
8081
#' ggplot(diamonds, aes(carat, price)) +
8182
#' geom_boxplot(aes(group = cut_width(carat, 0.25)))
83+
#' # Adjust the transparency of outliers using outlier.alpha
8284
#' ggplot(diamonds, aes(carat, price)) +
8385
#' geom_boxplot(aes(group = cut_width(carat, 0.25)), outlier.alpha = 0.1)
8486
#'

R/geom-histogram.r

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
#'
33
#' Visualise the distribution of a single continuous variable by dividing
44
#' the x axis into bins and counting the number of observations in each bin.
5-
#' Histograms (`geom_histogram`) display the count with bars; frequency
6-
#' polygons (`geom_freqpoly`) display the counts with lines. Frequency
5+
#' Histograms (`geom_histogram()`) display the counts with bars; frequency
6+
#' polygons (`geom_freqpoly()`) display the counts with lines. Frequency
77
#' polygons are more suitable when you want to compare the distribution
88
#' across the levels of a categorical variable.
99
#'
10-
#' `stat_bin` is suitable only for continuous x data. If your x data is
10+
#' `stat_bin()` is suitable only for continuous x data. If your x data is
1111
#' discrete, you probably want to use [stat_count()].
1212
#'
13-
#' By default, the underlying computation (`stat_bin`) uses 30 bins;
13+
#' By default, the underlying computation (`stat_bin()`) uses 30 bins;
1414
#' this is not a good default, but the idea is to get you experimenting with
1515
#' different bin widths. You may need to look at a few to uncover the full
1616
#' story behind your data.
1717
#'
1818
#' @section Aesthetics:
19-
#' `geom_histogram` uses the same aesthetics as [geom_bar()];
20-
#' `geom_freqpoly` uses the same aesthetics as [geom_line()].
19+
#' `geom_histogram()` uses the same aesthetics as [geom_bar()];
20+
#' `geom_freqpoly()` uses the same aesthetics as [geom_line()].
2121
#'
2222
#' @export
2323
#' @inheritParams layer
2424
#' @inheritParams geom_point
2525
#' @param geom,stat Use to override the default connection between
26-
#' `geom_histogram`/`geom_freqpoly` and `stat_bin`.
26+
#' `geom_histogram()`/`geom_freqpoly()` and `stat_bin()`.
2727
#' @examples
2828
#' ggplot(diamonds, aes(carat)) +
2929
#' geom_histogram()

R/geom-point.r

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
#' It can be used to compare one continuous and one categorical variable, or
66
#' two categorical variables, but a variation like [geom_jitter()],
77
#' [geom_count()], or [geom_bin2d()] is usually more
8-
#' appropriate.
9-
#'
10-
#' The \emph{bubblechart} is a scatterplot with a third variable mapped to
11-
#' the size of points. There are no special names for scatterplots where
12-
#' another variable is mapped to point shape or colour, however.
8+
#' appropriate. A _bubblechart_ is a scatterplot with a third variable
9+
#' mapped to the size of points.
1310
#'
1411
#' @section Overplotting:
1512
#' The biggest potential problem with a scatterplot is overplotting: whenever
@@ -47,6 +44,7 @@
4744
#' # Add aesthetic mappings
4845
#' p + geom_point(aes(colour = factor(cyl)))
4946
#' p + geom_point(aes(shape = factor(cyl)))
47+
#' # A "bubblechart":
5048
#' p + geom_point(aes(size = qsec))
5149
#'
5250
#' # Set aesthetics to fixed value

R/geom-smooth.r

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#' Smoothed conditional means
22
#'
33
#' Aids the eye in seeing patterns in the presence of overplotting.
4-
#' `geom_smooth` and `stat_smooth` are effectively aliases: they
5-
#' both use the same arguments. Use `geom_smooth` unless you want to
4+
#' `geom_smooth()` and `stat_smooth()` are effectively aliases: they
5+
#' both use the same arguments. Use `stat_smooth()` if you want to
66
#' display the results with a non-standard geom.
77
#'
88
#' Calculation is performed by the (currently undocumented)
9-
#' `predictdf` generic and its methods. For most methods the standard
9+
#' `predictdf()` generic and its methods. For most methods the standard
1010
#' 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
11+
#' exceptions are `loess()`, which uses a t-based approximation, and
12+
#' `glm()`, where the normal confidence interval is constructed on the link
1313
#' scale and then back-transformed to the response scale.
1414
#'
1515
#' @eval rd_aesthetics("geom", "smooth")
1616
#' @inheritParams layer
1717
#' @inheritParams geom_point
1818
#' @param geom,stat Use to override the default connection between
19-
#' `geom_smooth` and `stat_smooth`.
19+
#' `geom_smooth()` and `stat_smooth()`.
2020
#' @seealso See individual modelling functions for more details:
2121
#' [lm()] for linear smooths,
2222
#' [glm()] for generalised linear smooths, and

R/geom-text.r

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' Text
22
#'
3-
#' `geom_text` adds text directly to the plot. `geom_label` draws
3+
#' `geom_text()` adds text directly to the plot. `geom_label()` draws
44
#' a rectangle behind the text, making it easier to read.
55
#'
66
#' Note that the "width" and "height" of a text element are 0, so stacking
@@ -10,16 +10,16 @@
1010
#' space they occupy on the plot is not constant in data units: when you
1111
#' resize a plot, labels stay the same size, but the size of the axes changes.
1212
#'
13-
#' `geom_text` and `geom_label` both add a label for each row in the
13+
#' `geom_text()` and `geom_label()` add labels for each row in the
1414
#' data, even if coordinates x, y are set to single values in the call
15-
#' to `geom_label` or `geom_text`.
15+
#' to `geom_label()` or `geom_text()`.
1616
#' To add labels at specified points use [annotate()] with
1717
#' `annotate(geom = "text", ...)` or `annotate(geom = "label", ...)`.
1818
#'
1919
#' @eval rd_aesthetics("geom", "text")
20-
#' @section `geom_label`:
21-
#' Currently `geom_label` does not support the `angle` aesthetic and
22-
#' is considerably slower than `geom_text`. The `fill` aesthetic
20+
#' @section `geom_label()`:
21+
#' Currently `geom_label()` does not support the `angle` aesthetic and
22+
#' is considerably slower than `geom_text()`. The `fill` aesthetic
2323
#' controls the background colour of the label.
2424
#'
2525
#' @section Alignment:

R/guide-legend.r

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
#' multiple guides are displayed, not the contents of the guide itself.
5858
#' If 0 (default), the order is determined by a secret algorithm.
5959
#' @param ... ignored.
60-
#' @return A guide object
6160
#' @export
6261
#' @family guides
6362
#' @examples

R/labels.r

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ update_labels <- function(p, labels) {
1919
#' Modify axis, legend, and plot labels
2020
#'
2121
#' Good labels are critical for making your plots accessible to a wider
22-
#' audience. Ensure the axis and legend labels display the full variable name.
23-
#' Use the plot `title` and `subtitle` to explain the main findings.
24-
#' It's common to use the `caption` to provide information about the
25-
#' data source. `tag` can be used for adding identification tags.
22+
#' audience. Always ensure the axis and legend labels display the full
23+
#' variable name. Use the plot `title` and `subtitle` to explain the
24+
#' main findings. It's common to use the `caption` to provide information
25+
#' about the data source. `tag` can be used for adding identification tags
26+
#' to differentiate between multiple plots.
2627
#'
2728
#' You can also set axis and legend labels in the individual scales (using
28-
#' the first argument, the `name`). I recommend doing that if you're
29-
#' changing other scale options.
29+
#' the first argument, the `name`). If you're changing other scale options, this
30+
#' is recommended.
3031
#'
3132
#' @param label The text for the axis, plot title or caption below the plot.
3233
#' @param subtitle the text for the subtitle for the plot which will be

R/save.r

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#' ggsave("mtcars.pdf", width = 4, height = 4)
3333
#' ggsave("mtcars.pdf", width = 20, height = 20, units = "cm")
3434
#'
35+
#' # delete files with base::unlink()
3536
#' unlink("mtcars.pdf")
3637
#' unlink("mtcars.png")
3738
#'

R/scale-.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale,
502502
#' @param palette A palette function that when called with a single integer
503503
#' argument (the number of levels in the scale) returns the values that
504504
#' they should take
505-
#' @param name The name of the scale. Used as axis or legend title. If
505+
#' @param name The name of the scale. Used as the axis or legend title. If
506506
#' `waiver()`, the default, the name of the scale is taken from the first
507507
#' mapping used for that aesthetic. If `NULL`, the legend title will be
508508
#' omitted.

R/scale-continuous.r

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#' Position scales for continuous data (x & y)
22
#'
3-
#' `scale_x_continuous` and `scale_y_continuous` are the default
3+
#' `scale_x_continuous()` and `scale_y_continuous()` are the default
44
#' scales for continuous x and y aesthetics. There are three variants
55
#' that set the `trans` argument for commonly used transformations:
6-
#' `scale_*_log10`, `scale_*_sqrt` and `scale_*_reverse`.
6+
#' `scale_*_log10()`, `scale_*_sqrt()` and `scale_*_reverse()`.
77
#'
88
#' For simple manipulation of labels and limits, you may wish to use
99
#' [labs()] and [lims()] instead.
1010
#'
1111
#' @inheritParams continuous_scale
1212
#' @family position scales
13-
#' @param ... Other arguments passed on to `scale_(x|y)_continuous`
13+
#' @param ... Other arguments passed on to `scale_(x|y)_continuous()`
1414
#' @examples
1515
#' p1 <- ggplot(mpg, aes(displ, hwy)) +
1616
#' geom_point()

R/scale-gradient.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#' @param low,high Colours for low and high ends of the gradient.
1616
#' @param guide Type of legend. Use `"colourbar"` for continuous
1717
#' colour bar, or `"legend"` for discrete colour legend.
18-
#' @inheritDotParams continuous_scale -na.value -guide
18+
#' @inheritDotParams continuous_scale -na.value -guide -aesthetics
1919
#' @seealso [scales::seq_gradient_pal()] for details on underlying
2020
#' palette
2121
#' @family colour scales

R/stat-bin.r

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
88
#' The bin width of a date variable is the number of days in each time; the
99
#' bin width of a time variable is the number of seconds.
1010
#' @param bins Number of bins. Overridden by `binwidth`. Defaults to 30.
11-
#' @param center The center of one of the bins. Note that if center is above or
12-
#' below the range of the data, things will be shifted by an appropriate
13-
#' number of `width`s. To center on integers, for example, use
14-
#' `width = 1` and `center = 0`, even if `0` is outside the range
15-
#' of the data. At most one of `center` and `boundary` may be
16-
#' specified.
17-
#' @param boundary A boundary between two bins. As with `center`, things
18-
#' are shifted when `boundary` is outside the range of the data. For
19-
#' example, to center on integers, use `width = 1` and \code{boundary =
20-
#' 0.5}, even if `0.5` is outside the range of the data. At most one of
21-
#' `center` and `boundary` may be specified.
11+
#' @param center,boundary bin position specifiers. Only one, `center` or
12+
#' `boundary`, may be specified for a single plot. `center` specifies the
13+
#' center of one of the bins. `boundary` specifies the boundary between two
14+
#' bins. Note that if either is above or below the range of the data, things
15+
#' will be shifted by the appropriate integer multiple of `width`.
16+
#' For example, to center on integers use `width = 1` and `center = 0`, even
17+
#' if `0` is outside the range of the data. Alternatively, this same alignment
18+
#' can be specified with `width = 1` and `boundary = 0.5`, even if `0.5` is
19+
#' outside the range of the data.
2220
#' @param breaks Alternatively, you can supply a numeric vector giving
2321
#' the bin boundaries. Overrides `binwidth`, `bins`, `center`,
2422
#' and `boundary`.
@@ -36,7 +34,7 @@
3634
#'
3735
#' @seealso [stat_count()], which counts the number of cases at each x
3836
#' position, without binning. It is suitable for both discrete and continuous
39-
#' x data, whereas \link{stat_bin} is suitable only for continuous x data.
37+
#' x data, whereas `stat_bin()` is suitable only for continuous x data.
4038
#' @export
4139
#' @rdname geom_histogram
4240
stat_bin <- function(mapping = NULL, data = NULL,

R/stat-smooth.r

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
#' @param method Smoothing method (function) to use, eg. `lm`, `glm`,
2-
#' `gam`, `loess`, `MASS::rlm`.
1+
#' @param method Smoothing method (function) to use, accepts either a character vector,
2+
#' e.g. `"auto"`, `"lm"`, `"glm"`, `"gam"`, `"loess"` or a function, e.g.
3+
#' `MASS::rlm` or `mgcv::gam`, `base::lm`, or `base::loess`.
34
#'
45
#' For `method = "auto"` the smoothing method is chosen based on the
56
#' size of the largest group (across all panels). [loess()] is
@@ -8,8 +9,8 @@
89
#' `loess` gives a better appearance, but is \eqn{O(N^{2})}{O(N^2)} in memory,
910
#' so does not work for larger datasets.
1011
#'
11-
#' If you have fewer than 1,000 observations but want to use the same `gam`
12-
#' model that `method = "auto"` would use then set
12+
#' If you have fewer than 1,000 observations but want to use the same `gam()`
13+
#' model that `method = "auto"` would use, then set
1314
#' `method = "gam", formula = y ~ s(x, bs = "cs")`.
1415
#' @param formula Formula to use in smoothing function, eg. `y ~ x`,
1516
#' `y ~ poly(x, 2)`, `y ~ log(x)`

R/utilities-help.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ rd_aesthetics <- function(type, name) {
99
c(
1010
"@section Aesthetics:",
1111
paste0(
12-
"\\code{", type, "_", name, "} ",
12+
"\\code{", type, "_", name, "()} ",
1313
"understands the following aesthetics (required aesthetics are in bold):"
1414
),
1515
"\\itemize{",

man/annotation_logticks.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/borders.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/continuous_scale.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/coord_map.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/coord_trans.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)