-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Updating most visited docs (#2553) #2727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
5639ffa
78de69d
1b3c264
e2a2170
5693127
46b5836
120fb05
af337d2
3cef8ac
32a8673
736c368
6f6f472
0e072f2
31b6554
ab756df
884e543
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
#' Bar charts | ||
#' | ||
#' There are two types of bar charts: `geom_bar` makes the height of the | ||
#' There are two types of bar charts: `geom_bar()` makes the height of the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stylistic, but since we open with two types...: I would follow the colon with " |
||
#' bar proportional to the number of cases in each group (or if the | ||
#' `weight` aesthetic is supplied, the sum of the weights). If you want the | ||
#' heights of the bars to represent values in the data, use | ||
#' \link{geom_col} instead. `geom_bar` uses `stat_count` by | ||
#' default: it counts the number of cases at each x position. `geom_col` | ||
#' uses `stat_identity`: it leaves the data as is. | ||
#' `geom_col()` instead. `geom_bar()` uses `stat_count()` by | ||
#' default: it counts the number of cases at each x position. `geom_col()` | ||
#' uses `stat_identity()`: it leaves the data as is. | ||
#' | ||
#' A bar chart uses height to represent a value, and so the base of the | ||
#' bar must always be shown to produce a valid visual comparison. Naomi Robbins | ||
|
@@ -25,16 +25,16 @@ | |
#' @seealso | ||
#' [geom_histogram()] for continuous data, | ||
#' [position_dodge()] and [position_dodge2()] for creating side-by-side | ||
#' barcharts. | ||
#' bar charts. | ||
#' @export | ||
#' @inheritParams layer | ||
#' @inheritParams geom_point | ||
#' @param width Bar width. By default, set to 90\% of the resolution of the data. | ||
#' @param binwidth `geom_bar` no longer has a binwidth argument - if | ||
#' @param binwidth `geom_bar()` no longer has a binwidth argument - if | ||
#' you use it you'll get an warning telling to you use | ||
#' [geom_histogram()] instead. | ||
#' @param geom,stat Override the default connection between `geom_bar` and | ||
#' `stat_count`. | ||
#' @param geom,stat Override the default connection between `geom_bar()` and | ||
#' `stat_count()`. | ||
#' @examples | ||
#' # geom_bar is designed to make it easy to create bar charts that show | ||
#' # counts (or sums of weights) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ | |
#' if the notches of two boxes do not overlap, this suggests that the medians | ||
#' are significantly different. | ||
#' @param notchwidth For a notched box plot, width of the notch relative to | ||
#' the body (default 0.5) | ||
#' the body (default = `0.5`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, for now I have left this as is because default is not an actually argument name. I could change this a couple ways:
preference? other options? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like defaults to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
#' @param varwidth If `FALSE` (default) make a standard box plot. If | ||
#' `TRUE`, boxes are drawn with widths proportional to the | ||
#' square-roots of the number of observations in the groups (possibly | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
#' There is no one solution to this problem, but there are some techniques | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The section starting "The bubblechart" seems a bit weak. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm going to fill this PR just with minor edits and go back through for bigger changes to text in separate PRs. For instance here with "bubblechart", and with theme, etc. |
||
#' that can help. You can add additional information with | ||
#' [geom_smooth()], [geom_quantile()] or | ||
#' [geom_density_2d()]. If you have few unique x values, | ||
#' [geom_density_2d()]. If you have few unique `x` values, | ||
#' [geom_boxplot()] may also be useful. | ||
#' | ||
#' Alternatively, you can | ||
|
@@ -36,7 +36,7 @@ | |
#' a warning. If `TRUE`, missing values are silently removed. | ||
#' @param ... Other arguments passed on to [layer()]. These are | ||
#' often aesthetics, used to set an aesthetic to a fixed value, like | ||
#' `color = "red"` or `size = 3`. They may also be parameters | ||
#' `colour = "red"` or `size = 3`. They may also be parameters | ||
#' to the paired geom/stat. | ||
#' @inheritParams layer | ||
#' @export | ||
|
@@ -76,12 +76,6 @@ | |
#' geom_point(colour = "pink", size = 4) + | ||
#' geom_point(aes(shape = factor(cyl))) | ||
#' | ||
#' # These extra layers don't usually appear in the legend, but we can | ||
#' # force their inclusion | ||
#' p + geom_point(colour = "black", size = 4.5, show.legend = TRUE) + | ||
#' geom_point(colour = "pink", size = 4, show.legend = TRUE) + | ||
#' geom_point(aes(shape = factor(cyl))) | ||
#' | ||
#' # geom_point warns when missing values have been dropped from the data set | ||
#' # and not plotted, you can turn this off by setting na.rm = TRUE | ||
#' mtcars2 <- transform(mtcars, mpg = ifelse(runif(32) < 0.2, NA, mpg)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
#' | ||
#' Calculation is performed by the (currently undocumented) | ||
#' `predictdf` generic and its methods. For most methods the standard | ||
#' error bounds are computed using the [predict()] method - the | ||
#' error bounds are computed using the [predict()] method -- the | ||
#' exceptions are `loess` which uses a t-based approximation, and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. commas between the geom and the descriptor (i.e. " |
||
#' `glm` where the normal confidence interval is constructed on the link | ||
#' scale, and then back-transformed to the response scale. | ||
|
@@ -20,14 +20,14 @@ | |
#' @seealso See individual modelling functions for more details: | ||
#' [lm()] for linear smooths, | ||
#' [glm()] for generalised linear smooths, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're giving this one sentence structure (which we are, since there's a period after the last one) there should be an "and" added to the second to last list item. (Basically, "bulleted lists within sentences" structure: http://blog.apastyle.org/apastyle/2010/03/lists-part-5-bulleted-lists.html) |
||
#' [loess()] for local smooths | ||
#' [loess()] for local smooths. | ||
#' @export | ||
#' @examples | ||
#' ggplot(mpg, aes(displ, hwy)) + | ||
#' geom_point() + | ||
#' geom_smooth() | ||
#' | ||
#' # Use span to control the "wiggliness" of the default loess smoother | ||
#' # Use span to control the "wiggliness" of the default loess smoother. | ||
#' # The span is the fraction of points used to fit each local regression: | ||
#' # small numbers make a wigglier curve, larger numbers make a smoother curve. | ||
#' ggplot(mpg, aes(displ, hwy)) + | ||
|
@@ -43,8 +43,8 @@ | |
#' geom_point() + | ||
#' geom_smooth(method = lm, formula = y ~ splines::bs(x, 3), se = FALSE) | ||
#' | ||
#' # Smoothes are automatically fit to each group (defined by categorical | ||
#' # aesthetics or the group aesthetic) and for each facet | ||
#' # Smooths are automatically fit to each group (defined by categorical | ||
#' # aesthetics or the group aesthetic) and for each facet. | ||
#' | ||
#' ggplot(mpg, aes(displ, hwy, colour = class)) + | ||
#' geom_point() + | ||
|
@@ -73,7 +73,7 @@ | |
#' binomial_smooth(formula = y ~ splines::ns(x, 2)) | ||
#' | ||
#' # But in this case, it's probably better to fit the model yourself | ||
#' # so you can exercise more control and see whether or not it's a good model | ||
#' # so you can exercise more control and see whether or not it's a good model. | ||
#' } | ||
geom_smooth <- function(mapping = NULL, data = NULL, | ||
stat = "smooth", position = "identity", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
#' Continuous colour bar guide | ||
#' | ||
#' Colour bar guide shows continuous color scales mapped onto values. | ||
#' Colour bar guide shows continuous colour scales mapped onto values. | ||
#' Colour bar is available with `scale_fill` and `scale_colour`. | ||
#' For more information, see the inspiration for this function: | ||
#' \href{http://www.mathworks.com/help/techdoc/ref/colorbar.html}{Matlab's colorbar function}. | ||
#' | ||
#' Guides can be specified in each `scale_*` or in [guides()]. | ||
#' `guide="legend"` in `scale_*` is syntactic sugar for | ||
#' `guide=guide_legend()` (e.g. `scale_color_manual(guide = "legend")`). | ||
#' `guide=guide_legend()` (e.g. `scale_colour_manual(guide = "legend")`). | ||
#' As for how to specify the guide for each scale in more detail, | ||
#' see [guides()]. | ||
#' | ||
#' @inheritParams guide_legend | ||
#' @param barwidth A numeric or a [grid::unit()] object specifying | ||
#' the width of the colorbar. Default value is `legend.key.width` or | ||
#' the width of the colourbar. Default value is `legend.key.width` or | ||
#' `legend.key.size` in [theme()] or theme. | ||
#' @param barheight A numeric or a [grid::unit()] object specifying | ||
#' the height of the colorbar. Default value is `legend.key.height` or | ||
#' the height of the colourbar. Default value is `legend.key.height` or | ||
#' `legend.key.size` in [theme()] or theme. | ||
#' @param frame.colour A string specifying the colour of the frame | ||
#' drawn around the bar. If `NULL` (the default), no frame is drawn. | ||
#' @param frame.linewidth A numeric specifying the width of the frame | ||
#' drawn around the bar. | ||
#' @param frame.linetype A numeric specifying the linetype of the frame | ||
#' drawn around the bar. | ||
#' @param nbin A numeric specifying the number of bins for drawing colorbar. A | ||
#' smoother colorbar for a larger value. | ||
#' @param raster A logical. If `TRUE` then the colorbar is rendered as a | ||
#' raster object. If `FALSE` then the colorbar is rendered as a set of | ||
#' @param nbin A numeric specifying the number of bins for drawing colourbar. A | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add an article before "colourbar" (If you can have more than one, then "a," if not, then "the.") |
||
#' smoother colourbar for a larger value. | ||
#' @param raster A logical. If `TRUE` then the colourbar is rendered as a | ||
#' raster object. If `FALSE` then the colourbar is rendered as a set of | ||
#' rectangles. Note that not all graphics devices are capable of rendering | ||
#' raster image. | ||
#' @param ticks A logical specifying if tick marks on colorbar should be | ||
#' @param ticks A logical specifying if tick marks on colourbar should be | ||
#' visible. | ||
#' @param ticks.colour A string specifying the color of the tick marks. | ||
#' @param ticks.colour A string specifying the colour of the tick marks. | ||
#' @param ticks.linewidth A numeric specifying the width of the tick marks. | ||
#' @param draw.ulim A logical specifying if the upper limit tick marks should | ||
#' be visible. | ||
|
@@ -42,10 +42,10 @@ | |
#' One of "horizontal" or "vertical." | ||
#' @param default.unit A character string indicating [grid::unit()] | ||
#' for `barwidth` and `barheight`. | ||
#' @param reverse logical. If `TRUE` the colorbar is reversed. By default, | ||
#' @param reverse logical. If `TRUE` the colourbar is reversed. By default, | ||
#' the highest value is on the top and the lowest value is on the bottom | ||
#' @param available_aes A vector of charater strings listing the aesthetics | ||
#' for which a colorbar can be drawn. | ||
#' @param available_aes A vector of character strings listing the aesthetics | ||
#' for which a colourbar can be drawn. | ||
#' @param ... ignored. | ||
#' @return A guide object | ||
#' @export | ||
|
@@ -57,45 +57,45 @@ | |
#' p2 <- p1 + geom_point(aes(size = value)) | ||
#' | ||
#' # Basic form | ||
#' p1 + scale_fill_continuous(guide = "colorbar") | ||
#' p1 + scale_fill_continuous(guide = guide_colorbar()) | ||
#' p1 + guides(fill = guide_colorbar()) | ||
#' p1 + scale_fill_continuous(guide = "colourbar") | ||
#' p1 + scale_fill_continuous(guide = guide_colourbar()) | ||
#' p1 + guides(fill = guide_colourbar()) | ||
#' | ||
#' # Control styles | ||
#' | ||
#' # bar size | ||
#' p1 + guides(fill = guide_colorbar(barwidth = 0.5, barheight = 10)) | ||
#' p1 + guides(fill = guide_colourbar(barwidth = 0.5, barheight = 10)) | ||
#' | ||
#' # no label | ||
#' p1 + guides(fill = guide_colorbar(label = FALSE)) | ||
#' p1 + guides(fill = guide_colourbar(label = FALSE)) | ||
#' | ||
#' # no tick marks | ||
#' p1 + guides(fill = guide_colorbar(ticks = FALSE)) | ||
#' p1 + guides(fill = guide_colourbar(ticks = FALSE)) | ||
#' | ||
#' # label position | ||
#' p1 + guides(fill = guide_colorbar(label.position = "left")) | ||
#' p1 + guides(fill = guide_colourbar(label.position = "left")) | ||
#' | ||
#' # label theme | ||
#' p1 + guides(fill = guide_colorbar(label.theme = element_text(colour = "blue", angle = 0))) | ||
#' p1 + guides(fill = guide_colourbar(label.theme = element_text(colour = "blue", angle = 0))) | ||
#' | ||
#' # small number of bins | ||
#' p1 + guides(fill = guide_colorbar(nbin = 3)) | ||
#' p1 + guides(fill = guide_colourbar(nbin = 3)) | ||
#' | ||
#' # large number of bins | ||
#' p1 + guides(fill = guide_colorbar(nbin = 100)) | ||
#' p1 + guides(fill = guide_colourbar(nbin = 100)) | ||
#' | ||
#' # make top- and bottom-most ticks invisible | ||
#' p1 + scale_fill_continuous(limits = c(0,20), breaks = c(0, 5, 10, 15, 20), | ||
#' guide = guide_colorbar(nbin=100, draw.ulim = FALSE, draw.llim = FALSE)) | ||
#' guide = guide_colourbar(nbin=100, draw.ulim = FALSE, draw.llim = FALSE)) | ||
#' | ||
#' # guides can be controlled independently | ||
#' p2 + | ||
#' scale_fill_continuous(guide = "colorbar") + | ||
#' scale_fill_continuous(guide = "colourbar") + | ||
#' scale_size(guide = "legend") | ||
#' p2 + guides(fill = "colorbar", size = "legend") | ||
#' p2 + guides(fill = "colourbar", size = "legend") | ||
#' | ||
#' p2 + | ||
#' scale_fill_continuous(guide = guide_colorbar(direction = "horizontal")) + | ||
#' scale_fill_continuous(guide = guide_colourbar(direction = "horizontal")) + | ||
#' scale_size(guide = guide_legend(direction = "vertical")) | ||
guide_colourbar <- function( | ||
|
||
|
@@ -195,12 +195,12 @@ guide_train.colorbar <- function(guide, scale, aesthetic = NULL) { | |
|
||
# do nothing if scale are inappropriate | ||
if (length(intersect(scale$aesthetics, guide$available_aes)) == 0) { | ||
warning("colorbar guide needs appropriate scales: ", | ||
warning("colourbar guide needs appropriate scales: ", | ||
paste(guide$available_aes, collapse = ", ")) | ||
return(NULL) | ||
} | ||
if (scale$is_discrete()) { | ||
warning("colorbar guide needs continuous scales.") | ||
warning("colourbar guide needs continuous scales.") | ||
return(NULL) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
range ⇨ ranges (since there are now two of them to which we are referring)