|
57 | 57 | #' # positions.
|
58 | 58 | #' ggplot(sample_df, aes(x = group, y = value)) +
|
59 | 59 | #' geom_point() +
|
60 |
| -#' geom_point(group_means_df, aes(y = group_mean), colour = 'red', size = 3) |
| 60 | +#' geom_point(group_means_df, aes(y = group_mean, colour = 'red', size = 3)) |
61 | 61 | #'
|
62 | 62 | #' # Pattern 2
|
63 | 63 | #' # Same plot as above, declaring only the data frame in ggplot().
|
64 | 64 | #' # Note how the x and y aesthetics must now be declared in
|
65 | 65 | #' # each geom_point() layer.
|
66 | 66 | #' ggplot(sample_df) +
|
67 | 67 | #' geom_point(aes(x = group, y = value)) +
|
68 |
| -#' geom_point(group_means_df, aes(x = group, y = group_mean), colour = 'red', size = 3) |
| 68 | +#' geom_point(group_means_df, aes(x = group, y = group_mean, colour = 'red', size = 3)) |
69 | 69 | #'
|
70 | 70 | #' # Pattern 3
|
71 | 71 | #' # Alternatively, we can fully specify the plot in each layer. This
|
72 | 72 | #' # can be particularly useful when working with complex, multi-dataset graphics.
|
73 | 73 | #' ggplot() +
|
74 | 74 | #' geom_point(sample_df, aes(x = group, y = value)) +
|
75 |
| -#' geom_point(group_means_df, aes(x = group, y = group_mean), colour = 'red', size = 3) |
76 |
| -#' } |
| 75 | +#' geom_point(group_means_df, aes(x = group, y = group_mean, colour = 'red', size = 3)) |
77 | 76 | ggplot <- function(data = NULL, mapping = aes(), ...,
|
78 | 77 | environment = parent.frame()) {
|
79 | 78 | UseMethod("ggplot")
|
|
0 commit comments