Skip to content

Commit

Permalink
Re-roxygenize
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed May 7, 2012
1 parent 0ba6404 commit be4a1a4
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 26 deletions.
5 changes: 5 additions & 0 deletions NAMESPACE
Expand Up @@ -235,6 +235,8 @@ S3method(coord_distance,cartesian)
S3method(coord_distance,map)
S3method(coord_distance,polar)
S3method(coord_distance,trans)
S3method(coord_expand_defaults,default)
S3method(coord_expand_defaults,polar)
S3method(coord_labels,default)
S3method(coord_labels,flip)
S3method(coord_labels,polar)
Expand Down Expand Up @@ -358,6 +360,9 @@ S3method(scale_clone,position_d)
S3method(scale_dimension,continuous)
S3method(scale_dimension,discrete)
S3method(scale_dimension,position_d)
S3method(scale_expand,default)
S3method(scale_info,continuous)
S3method(scale_info,discrete)
S3method(scale_labels,continuous)
S3method(scale_labels,discrete)
S3method(scale_limits,default)
Expand Down
2 changes: 1 addition & 1 deletion man/continuous_scale.Rd
Expand Up @@ -6,7 +6,7 @@
name = NULL, breaks = waiver(),
minor_breaks = waiver(), labels = waiver(),
legend = NULL, limits = NULL, rescaler = rescale,
oob = censor, expand = c(0, 0), na.value = NA,
oob = censor, expand = waiver(), na.value = NA,
trans = "identity", guide = "legend")
}
\arguments{
Expand Down
6 changes: 1 addition & 5 deletions man/coord_cartesian.Rd
Expand Up @@ -2,16 +2,12 @@
\alias{coord_cartesian}
\title{Cartesian coordinates.}
\usage{
coord_cartesian(xlim = NULL, ylim = NULL, wise = FALSE)
coord_cartesian(xlim = NULL, ylim = NULL, wise = NULL)
}
\arguments{
\item{xlim}{limits for the x axis}

\item{ylim}{limits for the y axis}

\item{wise}{If \code{TRUE} will wisely expand the actual
range of the plot a little, in the way that setting the
limits on the scales does}
}
\description{
The Cartesian coordinate system is the most familiar, and
Expand Down
10 changes: 10 additions & 0 deletions man/coord_expand_defaults.Rd
@@ -0,0 +1,10 @@
\name{coord_expand_defaults}
\alias{coord_expand_defaults}
\title{Set the default expand values for the scale, if NA}
\usage{
coord_expand_defaults(coord, scale, aesthetic = NULL)
}
\description{
Set the default expand values for the scale, if NA
}

6 changes: 1 addition & 5 deletions man/coord_fixed.Rd
Expand Up @@ -4,18 +4,14 @@
\title{Cartesian coordinates with fixed relationship between x and y scales.}
\usage{
coord_fixed(ratio = 1, xlim = NULL, ylim = NULL,
wise = FALSE)
wise = NULL)
}
\arguments{
\item{ratio}{aspect ratio, expressed as \code{y / x}}

\item{xlim}{limits for the x axis}

\item{ylim}{limits for the y axis}

\item{wise}{If \code{TRUE} will wisely expand the actual
range of the plot a little, in the way that setting the
limits on the scales does}
}
\description{
A fixed scale coordinate system forces a specified ratio
Expand Down
6 changes: 1 addition & 5 deletions man/coord_polar.Rd
Expand Up @@ -2,8 +2,7 @@
\alias{coord_polar}
\title{Polar coordinates.}
\usage{
coord_polar(theta = "x", start = 0, direction = 1,
expand = FALSE)
coord_polar(theta = "x", start = 0, direction = 1)
}
\arguments{
\item{theta}{variable to map angle to (\code{x} or
Expand All @@ -13,9 +12,6 @@
radians}
\item{direction}{1, clockwise; -1, anticlockwise}
\item{expand}{should axes be expanded to slightly outside
the range of the data? (default: \code{FALSE})}
}
\description{
The polar coordinate system is most commonly used for pie
Expand Down
3 changes: 2 additions & 1 deletion man/coord_trans.Rd
Expand Up @@ -2,7 +2,8 @@
\alias{coord_trans}
\title{Transformed cartesian coordinate system.}
\usage{
coord_trans(xtrans = "identity", ytrans = "identity")
coord_trans(xtrans = "identity", ytrans = "identity",
limx = NULL, limy = NULL)
}
\arguments{
\item{ytrans}{transformer for x axis}
Expand Down
2 changes: 1 addition & 1 deletion man/discrete_scale.Rd
Expand Up @@ -4,7 +4,7 @@
\usage{
discrete_scale(aesthetics, scale_name, palette,
name = NULL, breaks = waiver(), labels = waiver(),
legend = NULL, limits = NULL, expand = c(0, 0),
legend = NULL, limits = NULL, expand = waiver(),
na.value = NA, drop = TRUE, guide = "legend")
}
\arguments{
Expand Down
4 changes: 2 additions & 2 deletions man/scale_continuous.Rd
Expand Up @@ -9,9 +9,9 @@
\alias{scale_y_sqrt}
\title{Continuous position scales (x & y).}
\usage{
scale_x_continuous(..., expand = c(0.05, 0))
scale_x_continuous(..., expand = waiver())

scale_y_continuous(..., expand = c(0.05, 0))
scale_y_continuous(..., expand = waiver())

scale_x_log10(...)

Expand Down
4 changes: 2 additions & 2 deletions man/scale_date.Rd
Expand Up @@ -3,10 +3,10 @@
\alias{scale_y_date}
\title{Position scale, date}
\usage{
scale_x_date(..., expand = c(0.05, 0), breaks = waiver(),
scale_x_date(..., expand = waiver(), breaks = waiver(),
minor_breaks = waiver())

scale_y_date(..., expand = c(0.05, 0), breaks = waiver(),
scale_y_date(..., expand = waiver(), breaks = waiver(),
minor_breaks = waiver())
}
\arguments{
Expand Down
4 changes: 2 additions & 2 deletions man/scale_datetime.Rd
Expand Up @@ -3,10 +3,10 @@
\alias{scale_y_datetime}
\title{Position scale, date}
\usage{
scale_x_datetime(..., expand = c(0.05, 0),
scale_x_datetime(..., expand = waiver(),
breaks = waiver(), minor_breaks = waiver())

scale_y_datetime(..., expand = c(0.05, 0),
scale_y_datetime(..., expand = waiver(),
breaks = waiver(), minor_breaks = waiver())
}
\arguments{
Expand Down
4 changes: 2 additions & 2 deletions man/scale_discrete.Rd
Expand Up @@ -3,9 +3,9 @@
\alias{scale_y_discrete}
\title{Discrete position.}
\usage{
scale_x_discrete(..., expand = c(0, 0.6))
scale_x_discrete(..., expand = waiver())

scale_y_discrete(..., expand = c(0, 0.6))
scale_y_discrete(..., expand = waiver())
}
\arguments{
\item{...}{common discrete scale parameters: \code{name},
Expand Down
110 changes: 110 additions & 0 deletions man/stat_smooth.Rd
Expand Up @@ -6,6 +6,11 @@
position = "identity", method = "auto",
formula = y ~ x, se = TRUE, n = 80, fullrange = FALSE,
level = 0.95, na.rm = FALSE, ...)

stat_smooth(mapping = NULL, data = NULL, geom = "smooth",
position = "identity", method = "auto",
formula = y ~ x, se = TRUE, n = 80, fullrange = FALSE,
level = 0.95, na.rm = FALSE, ...)
}
\arguments{
\item{method}{smoothing method (function) to use, eg. lm,
Expand Down Expand Up @@ -35,6 +40,33 @@
\item{...}{other arguments are passed to smoothing
function}

\item{method}{smoothing method (function) to use, eg. lm,
glm, gam, loess, rlm. For datasets with n < 1000 default
is \code{\link{loess}}. For datasets with 1000 or more
observations defaults to gam, see \code{\link[mgcv]{gam}}
for more details.}

\item{formula}{formula to use in smoothing function, eg.
\code{y ~ x}, \code{y ~ poly(x, 2)}, \code{y ~ log(x)}}

\item{se}{display confidence interval around smooth?
(TRUE by default, see level to control}

\item{fullrange}{should the fit span the full range of
the plot, or just the data}

\item{level}{level of confidence interval to use (0.95 by
default)}

\item{n}{number of points to evaluate smoother at}

\item{na.rm}{If \code{FALSE} (the default), removes
missing values with a warning. If \code{TRUE} silently
removes missing values.}

\item{...}{other arguments are passed to smoothing
function}

\item{mapping}{The aesthetic mapping, usually constructed
with \code{\link{aes}} or \code{\link{aes_string}}. Only
needs to be set at the layer level if you are overriding
Expand All @@ -53,10 +85,18 @@
value} \item{ymin}{lower pointwise confidence interval
around the mean} \item{ymax}{upper pointwise confidence
interval around the mean} \item{se}{standard error}

a data.frame with additional columns \item{y}{predicted
value} \item{ymin}{lower pointwise confidence interval
around the mean} \item{ymax}{upper pointwise confidence
interval around the mean} \item{se}{standard error}
}
\description{
Aids the eye in seeing patterns in the presence of
overplotting.

Aids the eye in seeing patterns in the presence of
overplotting.
}
\details{
Calculation is performed by the (currently undocumented)
Expand All @@ -67,6 +107,15 @@
\code{glm} where the normal confidence interval is
constructed on the link scale, and then back-transformed
to the response scale.

Calculation is performed by the (currently undocumented)
\code{predictdf} generic function and its methods. For
most methods the confidence bounds are computed using the
\code{\link{predict}} method - the exceptions are
\code{loess} which uses a t-based approximation, and for
\code{glm} where the normal confidence interval is
constructed on the link scale, and then back-transformed
to the response scale.
}
\examples{
\donttest{
Expand Down Expand Up @@ -121,6 +170,63 @@ qplot(Age, data=kyphosis, facets = . ~ Kyphosis, binwidth = 10)
qplot(Age, Kyphosis, data=kyphosis, position="jitter")
qplot(Age, Kyphosis, data=kyphosis, position=position_jitter(height=0.1))

qplot(Age, as.numeric(Kyphosis) - 1, data = kyphosis) +
stat_smooth(method="glm", family="binomial")
qplot(Age, as.numeric(Kyphosis) - 1, data=kyphosis) +
stat_smooth(method="glm", family="binomial", formula = y ~ ns(x, 2))
}
\donttest{
c <- ggplot(mtcars, aes(qsec, wt))
c + stat_smooth()
c + stat_smooth() + geom_point()

# Adjust parameters
c + stat_smooth(se = FALSE) + geom_point()

c + stat_smooth(span = 0.9) + geom_point()
c + stat_smooth(level = 0.99) + geom_point()
c + stat_smooth(method = "lm") + geom_point()

library(splines)
library(MASS)
c + stat_smooth(method = "lm", formula = y ~ ns(x,3)) +
geom_point()
c + stat_smooth(method = rlm, formula= y ~ ns(x,3)) + geom_point()

# The default confidence band uses a transparent colour.
# This currently only works on a limited number of graphics devices
# (including Quartz, PDF, and Cairo) so you may need to set the
# fill colour to a opaque colour, as shown below
c + stat_smooth(fill = "grey50", size = 2, alpha = 1)
c + stat_smooth(fill = "blue", size = 2, alpha = 1)

# The colour of the line can be controlled with the colour aesthetic
c + stat_smooth(fill="blue", colour="darkblue", size=2)
c + stat_smooth(fill="blue", colour="darkblue", size=2, alpha = 0.2)
c + geom_point() +
stat_smooth(fill="blue", colour="darkblue", size=2, alpha = 0.2)

# Smoothers for subsets
c <- ggplot(mtcars, aes(y=wt, x=mpg)) + facet_grid(. ~ cyl)
c + stat_smooth(method=lm) + geom_point()
c + stat_smooth(method=lm, fullrange = TRUE) + geom_point()

# Geoms and stats are automatically split by aesthetics that are factors
c <- ggplot(mtcars, aes(y=wt, x=mpg, colour=factor(cyl)))
c + stat_smooth(method=lm) + geom_point()
c + stat_smooth(method=lm, aes(fill = factor(cyl))) + geom_point()
c + stat_smooth(method=lm, fullrange=TRUE, alpha = 0.1) + geom_point()

# Use qplot instead
qplot(qsec, wt, data=mtcars, geom=c("smooth", "point"))

# Example with logistic regression
data("kyphosis", package="rpart")
qplot(Age, Kyphosis, data=kyphosis)
qplot(Age, data=kyphosis, facets = . ~ Kyphosis, binwidth = 10)
qplot(Age, Kyphosis, data=kyphosis, position="jitter")
qplot(Age, Kyphosis, data=kyphosis, position=position_jitter(height=0.1))

qplot(Age, as.numeric(Kyphosis) - 1, data = kyphosis) +
stat_smooth(method="glm", family="binomial")
qplot(Age, as.numeric(Kyphosis) - 1, data=kyphosis) +
Expand All @@ -131,5 +237,9 @@ qplot(Age, as.numeric(Kyphosis) - 1, data=kyphosis) +
\code{\link{lm}} for linear smooths, \code{\link{glm}}
for generalised linear smooths, \code{\link{loess}} for
local smooths

\code{\link{lm}} for linear smooths, \code{\link{glm}}
for generalised linear smooths, \code{\link{loess}} for
local smooths
}

0 comments on commit be4a1a4

Please sign in to comment.