Skip to content

Commit 2d5f6d3

Browse files
committed
Tweaking docs & pkgdown desc
Complete up to "layers"
1 parent fd66a9f commit 2d5f6d3

Some content is hidden

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

85 files changed

+402
-443
lines changed

R/geom-abline.r

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#' @include stat-.r
22
NULL
33

4-
#' Lines: horizontal, vertical, and specified by slope and intercept.
4+
#' Reference lines: horizontal, vertical, and diagonal
55
#'
6-
#' These paired geoms and stats add straight lines to a plot, either
7-
#' horizontal, vertical or specified by slope and intercept. These are useful
8-
#' for annotating plots.
6+
#' These geoms add reference lines (sometimes called rules) to a plot, either
7+
#' horizontal, vertical, or diagonal (specified by slope and intercept).
8+
#' These are useful for annotating plots.
99
#'
1010
#' These geoms act slightly different to other geoms. You can supply the
1111
#' parameters in two ways: either as arguments to the layer function,
@@ -21,8 +21,9 @@ NULL
2121
#'
2222
#' @section Aesthetics:
2323
#' These geoms are drawn using with \code{\link{geom_line}} so support the
24-
#' same aesthetics: alpha, colour, linetype and size. They also each have
25-
#' aesthetics that control the position of the line:
24+
#' same aesthetics: \code{alpha}, \code{colour}, \code{linetype} and
25+
#' \code{size}. They also each have aesthetics that control the position of
26+
#' the line:
2627
#'
2728
#' \itemize{
2829
#' \item \code{geom_vline}: \code{xintercept}

R/geom-bar.r

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,27 @@
44
#' bar proportional to the number of cases in each group (or if the
55
#' \code{weight} aethetic is supplied, the sum of the weights). If you want the
66
#' heights of the bars to represent values in the data, use
7-
#' \code{\link{geom_col}} instead.
7+
#' \link{geom_col} instead. \code{geom_bar} uses \code{stat_count} by
8+
#' default: it counts the number of cases at each x position. \code{geom_col}
9+
#' uses \code{stat_identity}: it leaves the data as is.
810
#'
9-
#' A bar chart maps the height of the bar to a variable, and so the base of the
11+
#' A bar chart uses height to represent a value, and so the base of the
1012
#' bar must always be shown to produce a valid visual comparison. Naomi Robbins
1113
#' has a nice
1214
#' \href{http://www.b-eye-network.com/view/index.php?cid=2468}{article on this
1315
#' topic}. This is why it doesn't make sense to use a log-scaled y axis with a
1416
#' bar chart.
1517
#'
16-
#' By default, multiple x's occurring in the same place will be stacked atop one
17-
#' another by \code{\link{position_stack}}. If you want them to be dodged
18-
#' side-to-side, see \code{\link{position_dodge}}. Finally,
19-
#' \code{\link{position_fill}} shows relative proportions at each x by stacking
20-
#' the bars and then stretching or squashing to the same height.
18+
#' By default, multiple bar occupying the same \code{x} position will be
19+
#' stacked atop one another by \code{\link{position_stack}}. If you want them
20+
#' to be dodged side-to-side, use \code{\link{position_dodge}}. Finally,
21+
#' \code{\link{position_fill}} shows relative proportions at each \code{x} by
22+
#' stacking the bars and then standardising each bar to have the same height.
2123
#'
2224
#' @section Aesthetics:
2325
#' \aesthetics{geom}{bar}
2426
#'
25-
#' @seealso \code{\link{geom_col}} which uses \code{stat="identity"} by default,
27+
#' @seealso
2628
#' \code{\link{geom_histogram}} for continuous data,
2729
#' \code{\link{position_dodge}} for creating side-by-side barcharts.
2830
#' @export
@@ -43,11 +45,9 @@
4345
#' # Total engine displacement of each class
4446
#' g + geom_bar(aes(weight = displ))
4547
#'
46-
#' # To show (e.g.) means, you need stat = "identity"
47-
#' df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
48-
#' ggplot(df, aes(trt, outcome)) +
49-
#' geom_bar(stat = "identity")
48+
#' # To show (e.g.) means, you need geom_col()
5049
#' # And, even more succinctly with geom_col()
50+
#' df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
5151
#' ggplot(df, aes(trt, outcome)) +
5252
#' geom_col()
5353
#' # But geom_point() displays exactly the same information and doesn't

R/geom-bin2d.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Add heatmap of 2d bin counts.
1+
#' Heatmap of 2d bin counts
22
#'
33
#' Divides the plane into rectangles, counts the number of cases in
44
#' each rectangle, and then (by default) maps the number of cases to the

R/geom-blank.r

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#' Blank, draws nothing.
1+
#' Draw nothing
22
#'
33
#' The blank geom draws nothing, but can be a useful way of ensuring common
4-
#' scales between different plots.
4+
#' scales between different plots. See \code{\link{expand_limits}} for
5+
#' more details.
56
#'
67
#' @export
78
#' @inheritParams layer

R/geom-boxplot.r

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
#' A Tukey box and whiskers plot.
1+
#' A box and whiskers plot (in the style of Tukey)
22
#'
3-
#' The boxplot gives a compact display of the distribution of a continuous
4-
#' variable. It displays a five number summary (defined by the median,
5-
#' two hinges, and two whiskers), and then individually all "outlying" points.
3+
#' The boxplot compactly displays the distribution of a continuous variable.
4+
#' It visualises five summary statistics (the median, two hinges
5+
#' and two whiskers), and all "outlying" points individually.
66
#'
7+
#' @section Summary statistics:
78
#' The lower and upper hinges correspond to the first and third quartiles
89
#' (the 25th and 75th percentiles). This differs slightly from the method used
910
#' by the \code{boxplot} function, and may be apparent with small samples.
1011
#' See \code{\link{boxplot.stats}} for for more information on how hinge
1112
#' positions are calculated for \code{boxplot}.
1213
#'
13-
#' The upper whisker extends from the hinge to the highest value that is within
14-
#' 1.5 * IQR of the hinge, where IQR is the inter-quartile range, or distance
15-
#' between the first and third quartiles. The lower whisker extends from the
16-
#' hinge to the lowest value within 1.5 * IQR of the hinge. Data beyond the
17-
#' end of the whiskers are outliers and plotted as points.
14+
#' The upper whisker extends from the hinge to the largest value no further than
15+
#' 1.5 * IQR from the hinge (where IQR is the inter-quartile range, or distance
16+
#' between the first and third quartiles). The lower whisker extends from the
17+
#' hinge to the smallest value at most 1.5 * IQR of the hinge. Data beyond the
18+
#' end of the whiskers are called "outlying" points and are plotted
19+
#' individually.
1820
#'
1921
#' In a notched box plot, the notches extend \code{1.58 * IQR / sqrt(n)}.
2022
#' This gives a roughly 95\% confidence interval for comparing medians.
@@ -23,9 +25,9 @@
2325
#' @section Aesthetics:
2426
#' \aesthetics{geom}{boxplot}
2527
#'
26-
#' @seealso \code{\link{stat_quantile}} to view quantiles conditioned on a
27-
#' continuous variable, \code{\link{geom_jitter}} for another way to look
28-
#' at conditional distributions.
28+
#' @seealso \code{\link{geom_quantile}} for continuous x,
29+
#' \code{\link{geom_violin}} for a richer display of the distribution, and
30+
#' \code{\link{geom_jitter}} for a useful technique for small data.
2931
#' @inheritParams layer
3032
#' @inheritParams geom_point
3133
#' @param geom,stat Use to override the default connection between

R/geom-col.r

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,5 @@
1-
#' Bars, rectangles with bases on x-axis
2-
#'
3-
#' This is an alternate version of \code{geom_bar} that maps the height of
4-
#' bars to an existing variable in your data. If you want the height of the
5-
#' bar to represent a count of cases, use \code{\link{geom_bar}}.
6-
#'
7-
#' A bar chart maps the height of the bar to a variable, and so the base of the
8-
#' bar must always be shown to produce a valid visual comparison. Naomi Robbins
9-
#' has a nice
10-
#' \href{http://www.b-eye-network.com/view/index.php?cid=2468}{article on this
11-
#' topic}. This is why it doesn't make sense to use a log-scaled y axis with a
12-
#' bar chart.
13-
#'
14-
#' By default, multiple x's occurring in the same place will be stacked atop one
15-
#' another by \code{\link{position_stack}}. If you want them to be dodged
16-
#' side-to-side, see \code{\link{position_dodge}}. Finally,
17-
#' \code{\link{position_fill}} shows relative proportions at each x by stacking
18-
#' the bars and then stretching or squashing to the same height.
19-
#'
20-
#' @section Aesthetics:
21-
#' \aesthetics{geom}{col}
22-
#'
23-
#' @seealso \code{\link{geom_bar}} to make the height of the bar proportional to
24-
#' the number of cases in each group or sum of weights,
25-
#' \code{\link{geom_histogram}} for continuous data,
26-
#' \code{\link{position_dodge}} for creating side-by-side barcharts.
271
#' @export
28-
#' @inheritParams layer
29-
#' @inheritParams geom_point
30-
#' @param width Bar width. By default, set to 90\% of the resolution of the data.
31-
#' @examples
32-
#' df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
33-
#' ggplot(df, aes(trt, outcome)) +
34-
#' geom_col()
35-
#' # But geom_point() displays exactly the same information and doesn't
36-
#' # require the y-axis to touch zero.
37-
#' ggplot(df, aes(trt, outcome)) +
38-
#' geom_point()
2+
#' @rdname geom_bar
393
geom_col <- function(mapping = NULL, data = NULL,
404
position = "stack",
415
...,

R/geom-contour.r

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
#' Display contours of a 3d surface in 2d.
1+
#' 2d contours of a 3d surface
22
#'
3-
#' To be a valid surface, the most only be a single combination of each
4-
#' unique \code{x} and \code{y} aesthetics. Contouring tends to work best
5-
#' when \code{x} and \code{y} form a (roughly) evenly spaced grid.
3+
#' ggplot2 can not draw true 3d surfaces, but you can use \code{geom_contour}
4+
#' and \code{\link{geom_tile}} to visualise 3d surfaces in 2d. To be a valid
5+
#' surface, the data must contain only a single row for each unique combination
6+
#' of the variables mapped to the \code{x} and \code{y} aesthetics. Contouring
7+
#' tends to work best when \code{x} and \code{y} form a (roughly) evenly
8+
#' spaced grid. If you data is not evenly spaced, you may want to interpolate
9+
#' to a grid before visualising.
610
#'
711
#' @section Aesthetics:
812
#' \aesthetics{geom}{contour}

R/geom-count.r

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
#' Count the number of observations at each location.
1+
#' Count overlapping points
22
#'
33
#' This is a variant \code{\link{geom_point}} that counts the number of
4-
#' observations at each location, then maps the count to point size. It
5-
#' useful when you have discrete data.
4+
#' observations at each location, then maps the count to point area. It
5+
#' useful when you have discrete data and overplotting.
66
#'
77
#' @section Aesthetics:
88
#' \aesthetics{geom}{point}
99
#'
1010
#' @param geom,stat Use to override the default connection between
1111
#' \code{geom_count} and \code{stat_sum}.
12+
#' @seealso For continuous \code{x} and \code{x}, use \code{\link{geom_bin2d}}.
1213
#' @inheritParams layer
1314
#' @inheritParams geom_point
1415
#' @export
@@ -23,7 +24,7 @@
2324
#' # counts of zero would be given size 0. Doesn't make much different
2425
#' # here because the smallest count is already close to 0.
2526
#' ggplot(mpg, aes(cty, hwy)) +
26-
#' geom_count()
27+
#' geom_count() +
2728
#' scale_size_area()
2829
#'
2930
#' # Display proportions instead of counts -------------------------------------

R/geom-density.r

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#' Display a smooth density estimate.
1+
#' Smoothed density estimates
22
#'
33
#' Computes and draws kernel density estimate, which is a smoothed version of
4-
#' the histogram.
4+
#' the histogram. This is a useful alternative to the histogram if for continuous
5+
#' data that comes from an underlying smooth distribution.
56
#'
67
#' @section Aesthetics:
78
#' \aesthetics{geom}{density}

R/geom-density2d.r

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
#' Contours from a 2d density estimate.
1+
#' Contours of a 2d density estimate
22
#'
33
#' Perform a 2D kernel density estimation using \code{\link[MASS]{kde2d}} and
44
#' display the results with contours. This can be useful for dealing with
5-
#' overplotting.
5+
#' overplotting. This is a 2d version of \code{\link{geom_density}}.
66
#'
77
#' @section Aesthetics:
88
#' \aesthetics{geom}{density_2d}
99
#'
1010
#' @seealso \code{\link{geom_contour}} for information about how contours
1111
#' are drawn; \code{\link{geom_bin2d}} for another way of dealing with
12-
#' overplotting
12+
#' overplotting.
1313
#' @param geom,stat Use to override the default connection between
1414
#' \code{geom_density_2d} and \code{stat_density_2d}.
1515
#' @inheritParams layer

0 commit comments

Comments
 (0)