From 43f757aec0188a8f8b6d4692fa1826c2e4763bdd Mon Sep 17 00:00:00 2001 From: hadley Date: Mon, 3 Mar 2008 16:50:50 +0000 Subject: [PATCH] Improvements to rdoc --- R/aaa-.r | 1 + R/aaa-rdoc.r | 18 ++++++++++-------- R/scale-.r | 5 +++++ man/aes-s3.rd | 4 +++- man/fullseq-20.rd | 2 +- man/print-ggplot-0n.rd | 5 ++--- man/save-examples-zh.rd | 3 ++- man/scale_brewer.rd | 5 +++-- man/scale_continuous.rd | 8 ++++++-- man/scale_date.rd | 5 +++-- man/scale_discrete.rd | 6 ++++-- man/scale_gradient.rd | 5 +++-- man/scale_gradient2.rd | 5 +++-- man/scale_grey.rd | 5 +++-- man/scale_hue.rd | 5 +++-- man/scale_identity.rd | 8 ++++++-- man/scale_linetype.rd | 3 ++- man/scale_manual.rd | 8 ++++++-- man/scale_pow.rd | 8 ++++++-- man/scale_prob.rd | 8 ++++++-- man/scale_shape.rd | 3 ++- man/scale_size.rd | 3 ++- 22 files changed, 82 insertions(+), 41 deletions(-) diff --git a/R/aaa-.r b/R/aaa-.r index 49edae4677..bdef5317bd 100644 --- a/R/aaa-.r +++ b/R/aaa-.r @@ -29,6 +29,7 @@ TopLevel <- proto(expr = { if (!prefix) return(.$objname) paste(.$class(), .$objname, sep="_") } + my_names <- function(.) .$my_name() myName <- function(.) { ps(firstUpper(.$class()), ps(firstUpper(strsplit(.$objname, "_")[[1]]))) diff --git a/R/aaa-rdoc.r b/R/aaa-rdoc.r index aacd9036dd..a3d0321fa5 100644 --- a/R/aaa-rdoc.r +++ b/R/aaa-rdoc.r @@ -44,16 +44,16 @@ TopLevel$rdoc_page <- function(.) { TopLevel$rdoc_name <- function(.) { ps( - "\\name{", .$myName(), "}\n" + "\\name{", .$my_name(), "}\n" ) } TopLevel$rdoc_aliases <- function(.) { - aliases <- c( + aliases <- unique(c( .$my_name(), - .$myName(), - if (exists("common", .) && !is.null(.$common) ) ps(.$class(), .$common, .$objname, sep="_", collapse=NULL) - ) + .$my_names(), + .$myName() + )) ps( "\\alias{", gsub("%", "\\%", aliases), "}\n" @@ -120,22 +120,24 @@ TopLevel$rdoc_formals <- function(.) { } + TopLevel$call <- function(.) { args <- .$rdoc_formals() is.missing.arg <- function(arg) sapply(arg, typeof) == "symbol" & sapply(arg, deparse) == "" equals <- ifelse(is.missing.arg(args), "", "=") ps( - .$my_name(), "(", + .$my_names(), ps("(", ps(names(args), equals, sapply(args, deparse), collapse=", "), - ")" + ")"), collapse=NULL ) } + # FIXME: need to generate usage statements for all common scales TopLevel$rdoc_usage <- function(.) { ps( - "\\usage{", .$call(), "}\n" + "\\usage{", ps(.$call(), collapse="\n"), "}\n" ) } diff --git a/R/scale-.r b/R/scale-.r index d0a6e19022..2809a5904b 100644 --- a/R/scale-.r +++ b/R/scale-.r @@ -77,6 +77,11 @@ Scale <- proto(TopLevel, expr={ "

This function returns a scale object.

" ) } + + my_names <- function(.) { + paste(.$class(), .$common, .$objname, sep="_") + } + # Guides # --------------------------------------------- legend_desc <- function(.) { diff --git a/man/aes-s3.rd b/man/aes-s3.rd index a81fc5cc9b..b640246f1a 100644 --- a/man/aes-s3.rd +++ b/man/aes-s3.rd @@ -8,8 +8,10 @@ \description{ Aesthetic mappings describe how variables in the data are mapped to visual properties (aesthetics) of geoms. } -\usage{aes(...)} +\usage{aes(x, y, ...)} \arguments{ +\item{x}{x value} +\item{y}{y value} \item{...}{List of name value pairs} } diff --git a/man/fullseq-20.rd b/man/fullseq-20.rd index 57dc62c353..d862e35468 100644 --- a/man/fullseq-20.rd +++ b/man/fullseq-20.rd @@ -13,6 +13,6 @@ All locations are multiples of size } \details{} -\seealso{\code{\link{round_any}}} +\seealso{\code{\link{reshape}{round_any}}} \examples{} \keyword{internal} diff --git a/man/print-ggplot-0n.rd b/man/print-ggplot-0n.rd index 0ff1c66b71..265e26728e 100644 --- a/man/print-ggplot-0n.rd +++ b/man/print-ggplot-0n.rd @@ -6,13 +6,12 @@ \description{ Print generic for ggplot. Plot on current graphics device. } -\usage{print.ggplot(x, newpage = is.null(vp), vp = NULL, save=ggopt()$save, ...)} +\usage{print.ggplot(x, newpage = is.null(vp), vp = NULL, ...)} \arguments{ \item{x}{plot to display} \item{newpage}{draw new (empty) page first?} \item{vp}{viewport to draw plot in} -\item{save}{other arguments passed on to \\code{\\link{ggplot_plot}}} -\item{...}{} +\item{...}{other arguments passed on to \\code{\\link{ggplot_plot}}} } \details{} diff --git a/man/save-examples-zh.rd b/man/save-examples-zh.rd index 4ad9b0056b..d475a6b96c 100644 --- a/man/save-examples-zh.rd +++ b/man/save-examples-zh.rd @@ -6,9 +6,10 @@ \description{ Cache output from all examples in ggplot directory } -\usage{save_examples(name = get_rev("."))} +\usage{save_examples(name = get_rev("."), verbose = FALSE)} \arguments{ \item{name}{} +\item{verbose}{} } \details{Produces: diff --git a/man/scale_brewer.rd b/man/scale_brewer.rd index 7d95f20ee1..49ab02fa6e 100644 --- a/man/scale_brewer.rd +++ b/man/scale_brewer.rd @@ -1,8 +1,8 @@ \name{ScaleBrewer} \alias{scale_brewer} -\alias{ScaleBrewer} \alias{scale_colour_brewer} \alias{scale_fill_brewer} +\alias{ScaleBrewer} \title{scale_brewer} \description{Colour brewer colour scales} \details{ @@ -10,7 +10,8 @@ See colorbrewer.org for more info This page describes \code{\link{scale_brewer}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_brewer(name=NULL, palette=1, type="qual", alpha=1, reverse=FALSE, labels=NULL, ...)} +\usage{scale_colour_brewer(name=NULL, palette=1, type="qual", alpha=1, reverse=FALSE, labels=NULL, ...) +scale_fill_brewer(name=NULL, palette=1, type="qual", alpha=1, reverse=FALSE, labels=NULL, ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{palette}{NULL} diff --git a/man/scale_continuous.rd b/man/scale_continuous.rd index a900d9d6c3..efdc5ef696 100644 --- a/man/scale_continuous.rd +++ b/man/scale_continuous.rd @@ -1,17 +1,21 @@ \name{ScaleContinuous} \alias{scale_continuous} -\alias{ScaleContinuous} \alias{scale_x_continuous} \alias{scale_y_continuous} \alias{scale_z_continuous} \alias{scale_xend_continuous} \alias{scale_yend_continuous} +\alias{ScaleContinuous} \title{scale_continuous} \description{Continuous position scale} \details{ This page describes \code{\link{scale_continuous}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...)} +\usage{scale_x_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...) +scale_y_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...) +scale_z_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...) +scale_xend_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...) +scale_yend_continuous(name=NULL, limits=c(NA, NA), breaks=NULL, labels=NULL, trans="identity", expand=c(0.05, 0), ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{limits}{numeric vector of length 2, giving the extent of the scale} diff --git a/man/scale_date.rd b/man/scale_date.rd index 3acaf2ba5d..87e1ea7669 100644 --- a/man/scale_date.rd +++ b/man/scale_date.rd @@ -1,8 +1,8 @@ \name{ScaleDate} \alias{scale_date} -\alias{ScaleDate} \alias{scale_x_date} \alias{scale_y_date} +\alias{ScaleDate} \title{scale_date} \description{Continuous scale for date variables} \details{ @@ -10,7 +10,8 @@ Currently somewhat broken due to lack of support for dates in R. This page describes \code{\link{scale_date}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_date(major=NULL, minor=NULL, format=NULL, name=NULL, ...)} +\usage{scale_x_date(major=NULL, minor=NULL, format=NULL, name=NULL, ...) +scale_y_date(major=NULL, minor=NULL, format=NULL, name=NULL, ...)} \arguments{ \item{major}{NULL} \item{minor}{NULL} diff --git a/man/scale_discrete.rd b/man/scale_discrete.rd index 081cddc90d..1f5cc53b89 100644 --- a/man/scale_discrete.rd +++ b/man/scale_discrete.rd @@ -1,15 +1,17 @@ \name{ScaleDiscrete} \alias{scale_discrete} -\alias{ScaleDiscrete} \alias{scale_x_discrete} \alias{scale_y_discrete} \alias{scale_z_discrete} +\alias{ScaleDiscrete} \title{scale_discrete} \description{Discrete position scale} \details{ This page describes \code{\link{scale_discrete}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_discrete(name=NULL, expand=c(0, 0.75), labels=NULL, ...)} +\usage{scale_x_discrete(name=NULL, expand=c(0, 0.75), labels=NULL, ...) +scale_y_discrete(name=NULL, expand=c(0, 0.75), labels=NULL, ...) +scale_z_discrete(name=NULL, expand=c(0, 0.75), labels=NULL, ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{expand}{numeric vector of length 2, giving multiplicative and additive expansion factors} diff --git a/man/scale_gradient.rd b/man/scale_gradient.rd index 21bc488a23..0ba152cc52 100644 --- a/man/scale_gradient.rd +++ b/man/scale_gradient.rd @@ -1,14 +1,15 @@ \name{ScaleGradient} \alias{scale_gradient} -\alias{ScaleGradient} \alias{scale_colour_gradient} \alias{scale_fill_gradient} +\alias{ScaleGradient} \title{scale_gradient} \description{Smooth colour gradient} \details{ This page describes \code{\link{scale_gradient}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_gradient(name=NULL, low=muted("darkblue"), high="yellow", space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...)} +\usage{scale_colour_gradient(name=NULL, low=muted("darkblue"), high="yellow", space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...) +scale_fill_gradient(name=NULL, low=muted("darkblue"), high="yellow", space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{low}{colour at low end of scale} diff --git a/man/scale_gradient2.rd b/man/scale_gradient2.rd index 5f30e4a583..42e3cd06a8 100644 --- a/man/scale_gradient2.rd +++ b/man/scale_gradient2.rd @@ -1,14 +1,15 @@ \name{ScaleGradient2} \alias{scale_gradient2} -\alias{ScaleGradient2} \alias{scale_colour_gradient2} \alias{scale_fill_gradient2} +\alias{ScaleGradient2} \title{scale_gradient2} \description{Smooth colour gradient, with midpoint} \details{ This page describes \code{\link{scale_gradient2}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_gradient2(name=NULL, low=muted("red"), mid="white", high=muted("blue"), midpoint=0, space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...)} +\usage{scale_colour_gradient2(name=NULL, low=muted("red"), mid="white", high=muted("blue"), midpoint=0, space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...) +scale_fill_gradient2(name=NULL, low=muted("red"), mid="white", high=muted("blue"), midpoint=0, space="rgb", limits=c(NA, NA), trans="identity", alpha=1, ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{low}{colour at low end of scale} diff --git a/man/scale_grey.rd b/man/scale_grey.rd index a7765ad4df..654b3809b9 100644 --- a/man/scale_grey.rd +++ b/man/scale_grey.rd @@ -1,8 +1,8 @@ \name{ScaleGrey} \alias{scale_grey} -\alias{ScaleGrey} \alias{scale_colour_grey} \alias{scale_fill_grey} +\alias{ScaleGrey} \title{scale_grey} \description{Grey colour scale} \details{ @@ -10,7 +10,8 @@ Based on ?gray.colors This page describes \code{\link{scale_grey}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_grey(name=NULL, start=0.2, end=0.8, labels=NULL, ...)} +\usage{scale_colour_grey(name=NULL, start=0.2, end=0.8, labels=NULL, ...) +scale_fill_grey(name=NULL, start=0.2, end=0.8, labels=NULL, ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{start}{starting grey colour (between 0 and 1)} diff --git a/man/scale_hue.rd b/man/scale_hue.rd index 2c5a6072e7..265d54df57 100644 --- a/man/scale_hue.rd +++ b/man/scale_hue.rd @@ -1,14 +1,15 @@ \name{ScaleHue} \alias{scale_hue} -\alias{ScaleHue} \alias{scale_colour_hue} \alias{scale_fill_hue} +\alias{ScaleHue} \title{scale_hue} \description{Colours that vary continuously in hue} \details{ This page describes \code{\link{scale_hue}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_hue(name=NULL, h=c(0, 360), l=65, c=100, alpha=1, labels=NULL, h.start=0, direction=1, ...)} +\usage{scale_colour_hue(name=NULL, h=c(0, 360), l=65, c=100, alpha=1, labels=NULL, h.start=0, direction=1, ...) +scale_fill_hue(name=NULL, h=c(0, 360), l=65, c=100, alpha=1, labels=NULL, h.start=0, direction=1, ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{h}{range of hues to use, in degrees} diff --git a/man/scale_identity.rd b/man/scale_identity.rd index 8bebba3ce3..e727f92902 100644 --- a/man/scale_identity.rd +++ b/man/scale_identity.rd @@ -1,17 +1,21 @@ \name{ScaleIdentity} \alias{scale_identity} -\alias{ScaleIdentity} \alias{scale_colour_identity} \alias{scale_fill_identity} \alias{scale_size_identity} \alias{scale_shape_identity} \alias{scale_linetype_identity} +\alias{ScaleIdentity} \title{scale_identity} \description{Don't remap values, use directly} \details{ This page describes \code{\link{scale_identity}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_identity(name=NULL, breaks=NULL, labels=NULL, ...)} +\usage{scale_colour_identity(name=NULL, breaks=NULL, labels=NULL, ...) +scale_fill_identity(name=NULL, breaks=NULL, labels=NULL, ...) +scale_size_identity(name=NULL, breaks=NULL, labels=NULL, ...) +scale_shape_identity(name=NULL, breaks=NULL, labels=NULL, ...) +scale_linetype_identity(name=NULL, breaks=NULL, labels=NULL, ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{breaks}{numeric vector indicating where breaks should lie} diff --git a/man/scale_linetype.rd b/man/scale_linetype.rd index 8575f249f9..2368592561 100644 --- a/man/scale_linetype.rd +++ b/man/scale_linetype.rd @@ -1,12 +1,13 @@ \name{ScaleLinetype} \alias{scale_linetype} +\alias{scale__linetype} \alias{ScaleLinetype} \title{scale_linetype} \description{Scale for line patterns} \details{ This page describes \code{\link{scale_linetype}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_linetype(name=NULL, expand=c(0, 0.75), labels=NULL, ...)} +\usage{scale__linetype(name=NULL, expand=c(0, 0.75), labels=NULL, ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{expand}{numeric vector of length 2, giving multiplicative and additive expansion factors} diff --git a/man/scale_manual.rd b/man/scale_manual.rd index ce59aa54b2..2a4f6ac323 100644 --- a/man/scale_manual.rd +++ b/man/scale_manual.rd @@ -1,17 +1,21 @@ \name{ScaleManual} \alias{scale_manual} -\alias{ScaleManual} \alias{scale_colour_manual} \alias{scale_fill_manual} \alias{scale_size_manual} \alias{scale_shape_manual} \alias{scale_linetype_manual} +\alias{ScaleManual} \title{scale_manual} \description{Simple way of manually controlling scale} \details{ This page describes \code{\link{scale_manual}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_manual(name=NULL, values=NULL, ...)} +\usage{scale_colour_manual(name=NULL, values=NULL, ...) +scale_fill_manual(name=NULL, values=NULL, ...) +scale_size_manual(name=NULL, values=NULL, ...) +scale_shape_manual(name=NULL, values=NULL, ...) +scale_linetype_manual(name=NULL, values=NULL, ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{values}{NULL} diff --git a/man/scale_pow.rd b/man/scale_pow.rd index 2c82fd5ead..1d0130a4dd 100644 --- a/man/scale_pow.rd +++ b/man/scale_pow.rd @@ -1,17 +1,21 @@ \name{ScalePow} \alias{scale_pow} -\alias{ScalePow} \alias{scale_x_pow} \alias{scale_y_pow} \alias{scale_z_pow} \alias{scale_xend_pow} \alias{scale_yend_pow} +\alias{ScalePow} \title{scale_pow} \description{Power scale} \details{ This page describes \code{\link{scale_pow}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...)} +\usage{scale_x_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...) +scale_y_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...) +scale_z_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...) +scale_xend_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...) +scale_yend_pow(name=NULL, limits=c(NA, NA), breaks=NULL, power=1, ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{limits}{numeric vector of length 2, giving the extent of the scale} diff --git a/man/scale_prob.rd b/man/scale_prob.rd index 5227e48dd9..cb79c60698 100644 --- a/man/scale_prob.rd +++ b/man/scale_prob.rd @@ -1,17 +1,21 @@ \name{ScaleProb} \alias{scale_prob} -\alias{ScaleProb} \alias{scale_x_prob} \alias{scale_y_prob} \alias{scale_z_prob} \alias{scale_xend_prob} \alias{scale_yend_prob} +\alias{ScaleProb} \title{scale_prob} \description{Probability scale} \details{ This page describes \code{\link{scale_prob}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...)} +\usage{scale_x_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...) +scale_y_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...) +scale_z_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...) +scale_xend_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...) +scale_yend_prob(name=NULL, limits=c(NA, NA), breaks=NULL, family="norm", ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{limits}{numeric vector of length 2, giving the extent of the scale} diff --git a/man/scale_shape.rd b/man/scale_shape.rd index 88e9573a95..2fe33cf7a1 100644 --- a/man/scale_shape.rd +++ b/man/scale_shape.rd @@ -1,12 +1,13 @@ \name{ScaleShape} \alias{scale_shape} +\alias{scale__shape} \alias{ScaleShape} \title{scale_shape} \description{Discrete position scale} \details{ This page describes \code{\link{scale_shape}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_shape(name=NULL, solid=TRUE, ...)} +\usage{scale__shape(name=NULL, solid=TRUE, ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{solid}{NULL} diff --git a/man/scale_size.rd b/man/scale_size.rd index 271da4e183..4939bfc5cd 100644 --- a/man/scale_size.rd +++ b/man/scale_size.rd @@ -1,12 +1,13 @@ \name{ScaleSize} \alias{scale_size} +\alias{scale__size} \alias{ScaleSize} \title{scale_size} \description{Size scale for continuous variable} \details{ This page describes \code{\link{scale_size}}, see \code{\link{layer}} and \code{\link{qplot}} for how to create a complete plot from individual components. } -\usage{scale_size(name=NULL, to=c(0.2, 3), ...)} +\usage{scale__size(name=NULL, to=c(0.2, 3), ...)} \arguments{ \item{name}{name of scale to appear in legend or on axis} \item{to}{numeric vector of length 2, giving minimum and maximum after transformation}