Skip to content

Commit b080149

Browse files
authored
Edits to gglopt() example code in roxygen comments
* wrap long lines in example code * Use consistent phrasing in comments across the three examples
1 parent 2b261d0 commit b080149

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

R/plot.r

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,40 +60,46 @@
6060
#' )
6161
#'
6262
#' # The following three code blocks create the same graphic, each using one
63-
#' # of the three patterns specified above. In each graphic, the group means
64-
#' # data frame is used to plot larger red points on top of the sample data.
63+
#' # of the three patterns specified above. In each graphic, the sample data
64+
#' # are plotted in the first layer and the group means data frame is used to
65+
#' # plot larger red points on top of the sample data in the second layer.
6566
#'
6667
#' # Pattern 1
67-
#' # Both the `data` and the `mapping` arguments are passed into the `ggplot()`
68-
#' # call. Note that we don't need to supply `mapping` or `data` arguments in
69-
#' # the first `geom_point()` layer because those arguments get passed along
70-
#' # from the `ggplot()` call.
68+
#' # Both the `data` and `mapping` arguments are passed into the `ggplot()`
69+
#' # call. Those arguments are omitted in the first `geom_point()` layer
70+
#' # because they get passed along from the `ggplot()` call. Note that the
71+
#' # second `geom_point()` layer re-uses the `x = group` aesthetic through
72+
#' # that mechanism but overrides the y-position aesthetic.
7173
#' ggplot(data = sample_df, mapping = aes(x = group, y = value)) +
7274
#' geom_point() +
73-
#' geom_point(mapping = aes(x = group, y = group_mean), data = group_means_df,
74-
#' colour = 'red', size = 3
75-
#' )
75+
#' geom_point(
76+
#' mapping = aes(y = group_mean), data = group_means_df,
77+
#' colour = 'red', size = 3
78+
#' )
7679
#'
7780
#' # Pattern 2
78-
#' # Same plot as above, passing in only the `data` argument in the `ggplot()`
79-
#' # call. Note how the `mapping` arguments must now be passed in for each
80-
#' # `geom_point()` layer because there are no `mapping` arguments passed
81-
#' # along from the `ggplot()` call.
81+
#' # Same plot as above, passing only the `data` argument into the `ggplot()`
82+
#' # call. The `mapping` arguments are now required in each `geom_point()`
83+
#' # layer because there is no `mapping` argument passed along from the
84+
#' # `ggplot()` call.
8285
#' ggplot(data = sample_df) +
8386
#' geom_point(mapping = aes(x = group, y = value)) +
84-
#' geom_point(mapping = aes(x = group, y = group_mean), data = group_means_df,
85-
#' colour = 'red', size = 3
87+
#' geom_point(
88+
#' mapping = aes(x = group, y = group_mean), data = group_means_df,
89+
#' colour = 'red', size = 3
8690
#' )
8791
#'
8892
#' # Pattern 3
89-
#' # Same plot as above, passing in neither the `data` or `mapping` arguments
90-
#' # to the `ggplot()` call. Both those arguments must then be fully specified
91-
#' # in each layer. This pattern can be particularly useful when creating more
92-
#' # complex graphics.
93+
#' # Same plot as above, passing neither the `data` or `mapping` arguments
94+
#' # into the `ggplot()` call. Both those arguments are now required in
95+
#' # each `geom_point()` layer. This pattern can be particularly useful when
96+
#' # creating more complex graphics with many layers using data from multiple
97+
#' # data frames.
9398
#' ggplot() +
9499
#' geom_point(mapping = aes(x = group, y = value), data = sample_df) +
95-
#' geom_point(mapping = aes(x = group, y = group_mean), data = group_means_df,
96-
#' colour = 'red', size = 3
100+
#' geom_point(
101+
#' mapping = aes(x = group, y = group_mean), data = group_means_df,
102+
#' colour = 'red', size = 3
97103
#' )
98104
ggplot <- function(data = NULL, mapping = aes(), ...,
99105
environment = parent.frame()) {

0 commit comments

Comments
 (0)