Skip to content

Commit 8faa879

Browse files
committed
Fix typo, reported by Mat Stigler
1 parent 3af088f commit 8faa879

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

R/quick-plot.r

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#' Quick plot
22
#'
3-
#' \code{qplot} is the basic plotting function in the ggplot2 package,
4-
#' designed to be familiar if you're used to \code{\link{plot}}
5-
#' from the base package. It is a convenient wrapper for creating
6-
#' a number of different types of plots using a consistent
3+
#' \code{qplot} is the basic plotting function in the ggplot2 package,
4+
#' designed to be familiar if you're used to \code{\link{plot}}
5+
#' from the base package. It is a convenient wrapper for creating
6+
#' a number of different types of plots using a consistent
77
#' calling scheme. See \url{http://had.co.nz/ggplot2/book/qplot.pdf}
88
#' for the chapter in the \code{ggplot2} book which describes the usage
99
#' of \code{qplot} in detail.
10-
#'
10+
#'
1111
#' @param x x values
1212
#' @param y y values
1313
#' @param ... other aesthetics passed for each layer
14-
#' @param data data frame to use (optional). If not specified, will create
14+
#' @param data data frame to use (optional). If not specified, will create
1515
#' one, extracting vectors from the current environment.
1616
#' @param facets faceting formula to use. Picks \code{\link{facet_wrap}} or
1717
#' \code{\link{facet_grid}} depending on whether the formula is one sided
1818
#' or two-sided
1919
#' @param margins whether or not margins will be displayed
20-
#' @param geom character vector specifying geom to use. Defaults to
21-
#' "point" if x and y are specified, and "histogram" is on x is specified.
20+
#' @param geom character vector specifying geom to use. Defaults to
21+
#' "point" if x and y are specified, and "histogram" if only x is specified.
2222
#' @param stat character vector specifying statistics to use
2323
#' @param position character vector giving position adjustment to use
2424
#' @param xlim limits for x axis
@@ -28,8 +28,8 @@
2828
#' @param xlab character vector or expression for x axis label
2929
#' @param ylab character vector or expression for y axis label
3030
#' @param asp the y/x aspect ratio
31-
#' @aliases qplot quickplot
32-
#' @export qplot quickplot
31+
#' @aliases qplot quickplot
32+
#' @export qplot quickplot
3333
#' @examples
3434
#' \donttest{
3535
#' # Use data from data.frame
@@ -59,17 +59,17 @@
5959
#' a <- 1:10
6060
#' b <- a ^ 2
6161
#' qplot(a, b)
62-
#' }
62+
#' }
6363
#' f()
64-
#'
64+
#'
6565
#' # qplot will attempt to guess what geom you want depending on the input
6666
#' # both x and y supplied = scatterplot
6767
#' qplot(mpg, wt, data = mtcars)
6868
#' # just x supplied = histogram
6969
#' qplot(mpg, data = mtcars)
7070
#' # just y supplied = scatterplot, with x = seq_along(y)
7171
#' qplot(y = mpg, data = mtcars)
72-
#'
72+
#'
7373
#' # Use different geoms
7474
#' qplot(mpg, wt, data = mtcars, geom="path")
7575
#' qplot(factor(cyl), wt, data = mtcars, geom=c("boxplot", "jitter"))
@@ -78,13 +78,13 @@ qplot <- function(x, y = NULL, ..., data, facets = NULL, margins=FALSE, geom = "
7878

7979
argnames <- names(as.list(match.call(expand.dots=FALSE)[-1]))
8080
arguments <- as.list(match.call()[-1])
81-
81+
8282
aesthetics <- compact(arguments[.all_aesthetics])
8383
aesthetics <- aesthetics[!is.constant(aesthetics)]
8484
aes_names <- names(aesthetics)
8585
aesthetics <- rename_aes(aesthetics)
8686
class(aesthetics) <- "uneval"
87-
87+
8888
if (missing(data)) {
8989
# If data not explicitly specified, will be pulled from workspace
9090
data <- data.frame()
@@ -115,46 +115,46 @@ qplot <- function(x, y = NULL, ..., data, facets = NULL, margins=FALSE, geom = "
115115

116116
env <- parent.frame()
117117
p <- ggplot(data, aesthetics, environment = env)
118-
118+
119119
if (is.null(facets)) {
120120
p <- p + facet_null()
121121
} else if (is.formula(facets) && length(facets) == 2) {
122122
p <- p + facet_wrap(facets)
123123
} else {
124124
p <- p + facet_grid(facets = deparse(facets), margins = margins)
125125
}
126-
126+
127127
if (!is.null(main)) p <- p + ggtitle(main)
128128

129129
# Add geoms/statistics
130130
if (is.proto(position)) position <- list(position)
131-
131+
132132
mapply(function(g, s, ps) {
133133
if(is.character(g)) g <- Geom$find(g)
134134
if(is.character(s)) s <- Stat$find(s)
135135
if(is.character(ps)) ps <- Position$find(ps)
136-
136+
137137
# Have to use non-standard evaluation because we can't evaluate ...
138138
params <- arguments[setdiff(names(arguments), c(aes_names, argnames))]
139139
# 1: mapply, 2: qplot, 3: caller of qplot
140140
params <- lapply(params, eval, parent.frame(3))
141-
141+
142142
p <<- p + layer(geom=g, stat=s, geom_params=params, stat_params=params, position=ps)
143143
}, geom, stat, position)
144-
144+
145145
logv <- function(var) var %in% strsplit(log, "")[[1]]
146146

147147
if (logv("x")) p <- p + scale_x_log10()
148148
if (logv("y")) p <- p + scale_y_log10()
149-
149+
150150
if (!is.na(asp)) p <- p + theme(aspect.ratio = asp)
151-
151+
152152
if (!missing(xlab)) p <- p + xlab(xlab)
153153
if (!missing(ylab)) p <- p + ylab(ylab)
154-
154+
155155
if (!missing(xlim)) p <- p + xlim(xlim)
156156
if (!missing(ylim)) p <- p + ylim(ylim)
157-
157+
158158
p
159159
}
160160
quickplot <- qplot

0 commit comments

Comments
 (0)