Permalink
Browse files

Re-roxygenise and fixes for R CMD check

  • Loading branch information...
1 parent ce703bf commit f9915d0784cc9bd733903f1658143687e2821854 @hadley hadley committed Feb 27, 2012
View
@@ -44,8 +44,8 @@
#' df <- data.frame(gp = factor(rep(letters[1:3], each = 10)),
#' y = rnorm(30))
#' # Compute sample mean and standard deviation in each group
-#' ds <- plyr::ddply(df, .(gp), summarise,
-#' mean = mean(y), sd = sd(y))
+#' library(plyr)
+#' ds <- ddply(df, .(gp), summarise, mean = mean(y), sd = sd(y))
#'
#' # Declare the data frame and common aesthetics.
#' # The summary data frame ds is used to plot
@@ -71,8 +71,6 @@
#' geom_errorbar(data = ds, aes(x = gp, y = mean,
#' ymin = mean - sd, ymax = mean + sd),
#' colour = 'red', width = 0.4)
-#'
-
ggplot <- function(data = NULL, ...) UseMethod("ggplot")
#' @S3method ggplot default
@@ -89,8 +87,7 @@ ggplot.default <- function(data = NULL, mapping = aes(), ...) {
#' @param environment in which evaluation of aesthetics should occur
#' @seealso \url{http://had.co.nz/ggplot2}
#' @method ggplot data.frame
-
-#' @S3method ggplot data.frame
+#' @export
ggplot.data.frame <- function(data, mapping=aes(), ..., environment = globalenv()) {
if (!missing(mapping) && !inherits(mapping, "uneval")) stop("Mapping should be created with aes or aes_string")
View
@@ -7,6 +7,10 @@
#' between breaks. For more information about the first two, see
#' \code{\link{continuous_scale}}, for more information about the last,
#' see \code{\link[scales]{date_breaks}}`.
+#' @param minor_breaks Either \code{NULL} for no minor breaks, \code{waiver()}
+#' for the default breaks (one minor break between each major break), a
+#' numeric vector of positions, or a function that given the limits returns
+#' a vector of minor breaks.
#' @family position scales
#' @export
#' @examples
View
@@ -8,6 +8,10 @@
#' between breaks. For more information about the first two, see
#' \code{\link{continuous_scale}}, for more information about the last,
#' see \code{\link[scales]{date_breaks}}`.
+#' @param minor_breaks Either \code{NULL} for no minor breaks, \code{waiver()}
+#' for the default breaks (one minor break between each major break), a
+#' numeric vector of positions, or a function that given the limits returns
+#' a vector of minor breaks.
#' @export
#' @examples
#' start <- ISOdate(2001, 1, 1, tz = "")
View
@@ -15,10 +15,10 @@
}
\description{
This is a special version of \code{\link{geom_raster}}
- optimised for static anotations that are the same in
- every panel. These anotations will not affect scales
+ optimised for static annotations that are the same in
+ every panel. These annotations will not affect scales
(i.e. the x and y axes will not grow to cover the range
- of the raster, and the raster must already have it's own
+ of the raster, and the raster must already have its own
colours).
}
\details{
View
@@ -17,7 +17,7 @@
The Cartesian coordinate system is the most familiar, and
common, type of coordinate system. Setting limits on the
coordinate system will zoom the plot (like you're looking
- at it with a magnifying class), and will not change the
+ at it with a magnifying glass), and will not change the
underlying data like setting limits on a scale will.
}
\examples{
View
@@ -37,6 +37,6 @@ qplot(mpg, wt, data = mtcars) + coord_equal(ratio = 1)
qplot(mpg, wt, data = mtcars) + coord_equal(ratio = 5)
qplot(mpg, wt, data = mtcars) + coord_equal(ratio = 1/5)
-# Resize the plot to see that the specified aspect ratio is mantained
+# Resize the plot to see that the specified aspect ratio is maintained
}
View
@@ -38,7 +38,7 @@
\item{as.table}{If \code{TRUE}, the default, the facets
are laid out like a table with highest values at the
- bottom-right. If \code{FALSE}, the facet are laid out
+ bottom-right. If \code{FALSE}, the facets are laid out
like a plot with the highest value at the top-right.}
\item{shrink}{If \code{TRUE}, will shrink scales to fit
View
@@ -23,7 +23,7 @@
\item{as.table}{If \code{TRUE}, the default, the facets
are laid out like a table with highest values at the
- bottom-right. If \code{FALSE}, the facet are laid out
+ bottom-right. If \code{FALSE}, the facets are laid out
like a plot with the highest value at the top-right.}
\item{drop}{If \code{TRUE}, the default, all factor
View
@@ -26,9 +26,6 @@
need to refit the model with \code{na.action =
na.exclude}.
}
-\details{
- The following statistics will be added to the data frame:
-}
\examples{
mod <- lm(mpg ~ wt, data = mtcars)
head(fortify(mod))
View
@@ -12,7 +12,7 @@
\item{...}{not used by this method}
}
\description{
- This function turns a map into a data frame than can more
+ This function turns a map into a data frame that can more
easily be plotted with ggplot2.
}
\examples{
View
@@ -21,14 +21,14 @@
}
\description{
A fluctutation diagram is a graphical representation of a
- contingency table. This fuction currently only supports
- 2D contingency tabless but extension to more should be
- relatively straightforward.
+ contingency table. This function only supports 2D
+ contingency tables at present but extension to higher
+ dimensions should be relatively straightforward.
}
\details{
With the default size fluctuation diagram, area is
proportional to the count (length of sides proportional
- to sqrt(count))
+ to sqrt(count)).
}
\examples{
ggfluctuation(table(movies$Action, movies$Comedy))
View
@@ -19,9 +19,9 @@
}
\description{
The missing values plot is a useful tool to get a rapid
- overview of the number of missings in a dataset. It's
- strength is much more apparent when used with interactive
- graphics, as you can see in Mondrian
+ overview of the number and pattern of missing values in a
+ dataset. Its strength is much more apparent when used
+ with interactive graphics, as you can see in Mondrian
(\url{http://rosuda.org/mondrian}) where this plot was
copied from.
}
View
@@ -10,7 +10,73 @@
\item{...}{other arguments passed to specific methods}
}
\description{
- Create a new ggplot plot
+ \code{ggplot()} initializes a ggplot object. It can be
+ used to declare the input data frame for a graphic and to
+ specify the set of plot aesthetics intended to be common
+ throughout all subsequent layers unless specifically
+ overridden.
+}
+\details{
+ \code{ggplot()} is typically used to construct a plot
+ incrementally, using the + operator to add layers to the
+ existing ggplot object. This is advantageous in that the
+ code is explicit about which layers are added and the
+ order in which they are added. For complex graphics with
+ multiple layers, initialization with \code{ggplot} is
+ recommended.
+
+ There are three common ways to invoke \code{ggplot}:
+ \itemize{ \item \code{ggplot(df, aes(x, y, <other
+ aesthetics>))} \item \code{ggplot(df)} \item
+ \code{ggplot()} } The first method is recommended if all
+ layers use the same data and the same set of aesthetics,
+ although this method can also be used to add a layer
+ using data from another data frame. See the first example
+ below. The second method specifies the default data frame
+ to use for the plot, but no aesthetics are defined up
+ front. This is useful when one data frame is used
+ predominantly as layers are added, but the aesthetics may
+ vary from one layer to another. The third method
+ initializes a skeleton \code{ggplot} object which is
+ fleshed out as layers are added. This method is useful
+ when multiple data frames are used to produce different
+ layers, as is often the case in complex graphics.
+
+ The examples below illustrate how these methods of
+ invoking \code{ggplot} can be used in constructing a
+ graphic.
+}
+\examples{
+df <- data.frame(gp = factor(rep(letters[1:3], each = 10)),
+ y = rnorm(30))
+# Compute sample mean and standard deviation in each group
+library(plyr)
+ds <- ddply(df, .(gp), summarise, mean = mean(y), sd = sd(y))
+
+# Declare the data frame and common aesthetics.
+# The summary data frame ds is used to plot
+# larger red points in a second geom_point() layer.
+# If the data = argument is not specified, it uses the
+# declared data frame from ggplot(); ditto for the aesthetics.
+ggplot(df, aes(x = gp, y = y)) +
+ geom_point() +
+ geom_point(data = ds, aes(y = mean),
+ colour = 'red', size = 3)
+# Same plot as above, declaring only the data frame in ggplot().
+# Note how the x and y aesthetics must now be declared in
+# each geom_point() layer.
+ggplot(df) +
+ geom_point(aes(x = gp, y = y)) +
+ geom_point(data = ds, aes(x = gp, y = mean),
+ colour = 'red', size = 3)
+# Set up a skeleton ggplot object and add layers:
+ggplot() +
+ geom_point(data = df, aes(x = gp, y = y)) +
+ geom_point(data = ds, aes(x = gp, y = mean),
+ colour = 'red', size = 3) +
+ geom_errorbar(data = ds, aes(x = gp, y = mean,
+ ymin = mean - sd, ymax = mean + sd),
+ colour = 'red', width = 0.4)
}
\seealso{
\url{http://had.co.nz/ggplot2}
View
@@ -8,7 +8,7 @@
\item{...}{List of scale guide pairs}
}
\value{
- A list containing mapping between scale and guide.
+ A list containing the mapping between scale and guide.
}
\description{
Guides for each scale can be set in call of
@@ -23,7 +23,7 @@ dat <- data.frame(x = 1:5, y = 1:5, p = 1:5, q = factor(1:5),
r = factor(1:5))
p <- ggplot(dat, aes(x, y, colour = p, size = q, shape = r)) + geom_point()
-# without guide specificatoin
+# without guide specification
p
# Show colorbar guide for colour.
View
@@ -1,7 +1,7 @@
\name{qplot}
\alias{qplot}
\alias{quickplot}
-\title{A convenient wrapper function for creating simple ggplot plot objects.}
+\title{Quick plot}
\usage{
qplot(x, y = NULL, ..., data, facets = NULL,
margins = FALSE, geom = "auto", stat = list(NULL),
@@ -57,8 +57,14 @@
\item{asp}{the y/x aspect ratio}
}
\description{
- \code{qplot} has been designed to be familiar if you're
- used to \code{\link{plot}}.
+ \code{qplot} is the basic plotting function in the
+ ggplot2 package, designed to be familiar if you're used
+ to \code{\link{plot}} from the base package. It is a
+ convenient wrapper for creating a number of different
+ types of plots using a consistent calling scheme. See
+ \url{http://had.co.nz/ggplot2/book/qplot.pdf} for the
+ chapter in the \code{ggplot2} book which describes the
+ usage of \code{qplot} in detail.
}
\examples{
\donttest{
View
@@ -17,6 +17,12 @@
\code{\link{continuous_scale}}, for more information
about the last, see \code{\link[scales]{date_breaks}}`.}
+ \item{minor_breaks}{Either \code{NULL} for no minor
+ breaks, \code{waiver()} for the default breaks (one minor
+ break between each major break), a numeric vector of
+ positions, or a function that given the limits returns a
+ vector of minor breaks.}
+
\item{...}{common continuous scale parameters:
\code{name}, \code{breaks}, \code{labels},
\code{na.value}, \code{limits} and \code{trans}. See
View
@@ -17,6 +17,12 @@
\code{\link{continuous_scale}}, for more information
about the last, see \code{\link[scales]{date_breaks}}`.}
+ \item{minor_breaks}{Either \code{NULL} for no minor
+ breaks, \code{waiver()} for the default breaks (one minor
+ break between each major break), a numeric vector of
+ positions, or a function that given the limits returns a
+ vector of minor breaks.}
+
\item{...}{common continuous scale parameters:
\code{name}, \code{breaks}, \code{labels},
\code{na.value}, \code{limits} and \code{trans}. See
View
@@ -5,8 +5,8 @@
xlim(...)
}
\arguments{
- \item{...}{if numeric, will create a continuos scale, if
- factor or character, will create a discrete scale}
+ \item{...}{if numeric, will create a continuous scale, if
+ factor or character, will create a discrete scale.}
}
\description{
Convenience function to set the limits of the x axis.
View
@@ -5,8 +5,8 @@
ylim(...)
}
\arguments{
- \item{...}{if numeric, will create a continuos scale, if
- factor or character, will create a discrete scale}
+ \item{...}{if numeric, will create a continuous scale, if
+ factor or character, will create a discrete scale.}
}
\description{
Convenience function to set the limits of the y axis.

0 comments on commit f9915d0

Please sign in to comment.