Browse files

First pass at autoplot implementation

  • Loading branch information...
1 parent fb0a0b9 commit a9879a20aa7d5bb68d7609a4c4d2e7e5e8757c27 @BrianDiggs BrianDiggs committed Aug 18, 2011
Showing with 45 additions and 9 deletions.
  1. +1 −0 DESCRIPTION
  2. +1 −0 NAMESPACE
  3. +16 −9 R/autoplot.r
  4. +27 −0 man/autoplot.Rd
View
1 DESCRIPTION
@@ -188,3 +188,4 @@ Collate:
'geom-raster.r'
'annotation-raster.r'
'annotation-map.r'
+ 'autoplot.r'
View
1 NAMESPACE
@@ -206,6 +206,7 @@ import(scales)
S3method("[",uneval)
S3method("+",ggplot)
S3method(as.character,uneval)
+S3method(autoplot,default)
S3method(cbind,gtable)
S3method(coord_aspect,fixed)
S3method(coord_aspect,map)
View
25 R/autoplot.r
@@ -1,15 +1,22 @@
-# Create a new autoplot
-# autoplot uses ggplot2 to draw a particular plot for a particular class in a single command
-#
-# @seealso \url{http://had.co.nz/ggplot2}
-# @alias autoplot
-# @alias autoplot.default
-# @keyword hplot
-# @arguments object of a class with an autoplot method
-# @arguments other arguments passed to specific methods
+#' Create a complete ggplot appropriate to a particular data type
+#'
+#' autoplot uses ggplot2 to draw a particular plot for a particular class
+#' in a single command. This defines the S3 generic that other classes and
+#' packages can extend.
+#'
+#' @param x an object
+#' @param ... other arguments passed to specific methods
+#' @return a ggplot object
+#' @method autoplot default
+#' @S3method autoplot default
+#' @export
+#' @seealso \url{http://had.co.nz/ggplot2}
+#' @seealso \code{\link{ggplot}}
+#' @seealso \code{\link{fortify}}
autoplot <- function(x, ...) {
UseMethod("autoplot")
}
+
autoplot.default <- function(x, ...) {
error.msg <- paste("Objects of type",class(x),"not supported by autoplot. Please use qplot() or ggplot() instead.\n")
stop(error.msg)
View
27 man/autoplot.Rd
@@ -0,0 +1,27 @@
+\name{autoplot}
+\alias{autoplot}
+\title{Create a complete ggplot appropriate to a particular data type}
+\usage{
+ \method{autoplot}{default} (x, ...)
+}
+\arguments{
+ \item{x}{an object}
+
+ \item{...}{other arguments passed to specific methods}
+}
+\value{
+ a ggplot object
+}
+\description{
+ autoplot uses ggplot2 to draw a particular plot for a
+ particular class in a single command. This defines the S3
+ generic that other classes and packages can extend.
+}
+\seealso{
+ \url{http://had.co.nz/ggplot2}
+
+ \code{\link{ggplot}}
+
+ \code{\link{fortify}}
+}
+

0 comments on commit a9879a2

Please sign in to comment.