Skip to content

Commit

Permalink
Removed xxx.r (build_accessor file) and @name tags, added functions t…
Browse files Browse the repository at this point in the history
…o geoms/positions/stats
  • Loading branch information
JakeRuss committed Jun 28, 2011
1 parent b5edd86 commit ede677c
Show file tree
Hide file tree
Showing 111 changed files with 417 additions and 136 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Expand Up @@ -156,5 +156,4 @@ Collate:
'utilities.r'
'xxx-codegen.r'
'xxx-digest.r'
'xxx.r'
'zxx.r'
7 changes: 5 additions & 2 deletions R/geom-abline.r
Expand Up @@ -10,8 +10,7 @@
#' (\code{geom_abline(intercept=0, slope=1)}) then the line will be the same
#' in all panels. If the intercept and slope are stored in the data, then
#' they can vary from panel to panel. See the examples for more ideas.
#'
#' @name geom_abline
#'
#' @seealso \code{\link{stat_smooth}} to add lines derived from the data,
#' \code{\link{geom_hline}} for horizontal lines,
#' \code{\link{geom_vline}} for vertical lines
Expand Down Expand Up @@ -49,6 +48,10 @@
#' # It's actually a bit easier to do this with stat_smooth
#' p + geom_smooth(aes(group=cyl), method="lm")
#' p + geom_smooth(aes(group=cyl), method="lm", fullrange=TRUE)
geom_abline <- function (mapping = NULL, data = NULL, stat = "abline", position = "identity", ...) {
GeomAbline$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomAbline <- proto(Geom, {
objname <- "abline"

Expand Down
7 changes: 5 additions & 2 deletions R/geom-bar-.r
Expand Up @@ -28,8 +28,7 @@
#' Naomi Robbins has a nice
#' \href{http://www.b-eye-network.com/view/index.php?cid=2468}{article on this topic}.
#' This is the reason it doesn't make sense to use a log-scaled y axis with a bar chart
#'
#' @name geom_bar
#'
#' @seealso \code{\link{stat_bin}} for more details of the binning alogirithm,
#' \code{\link{position_dodge}} for creating side-by-side barcharts,
#' \code{\link{position_stack}} for more info on stacking,
Expand Down Expand Up @@ -103,6 +102,10 @@
#' "suv", "compact", "2seater", "subcompact", "pickup"))
#' m <- ggplot(mpg, aes(manufacturer, fill=class))
#' m + geom_bar()
geom_bar <- function (mapping = NULL, data = NULL, stat = "bin", position = "stack", ...) {
GeomBar$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomBar <- proto(Geom, {
objname <- "bar"

Expand Down
5 changes: 4 additions & 1 deletion R/geom-bar-histogram.r
Expand Up @@ -9,7 +9,6 @@
#' may need to look at a few to uncover the full story behind your data.
#'
#'
#' @name geom_histogram
#' @export
#' @examples
#' # Simple examples
Expand Down Expand Up @@ -104,6 +103,10 @@
#' # Which looks better when the distributions are more distinct
#' ggplot(diamonds, aes(depth, fill = cut)) +
#' geom_density(alpha = 0.2) + xlim(55, 70)
geom_histogram <- function (mapping = NULL, data = NULL, stat = "bin", position = "stack", ...) {
GeomHistogram$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomHistogram <- proto(GeomBar, {
objname <- "histogram"

Expand Down
7 changes: 5 additions & 2 deletions R/geom-bin2d.r
@@ -1,13 +1,16 @@
#' Add heatmap of 2d bin counts.
#'
#' @name geom_bin2d
#'
#' @export
#' @examples
#' d <- ggplot(diamonds, aes(x = x, y = y)) + xlim(4,10) + ylim(4,10)
#' d + geom_bin2d()
#' d + geom_bin2d(binwidth = c(0.1, 0.1))
#'
#' # See ?stat_bin2d for more examples
geom_bin2d <- function (mapping = NULL, data = NULL, stat = "bin2d", position = "identity", ...) {
GeomBin2d$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomBin2d <- proto(Geom, {
draw <- function(., data, scales, coordinates, ...) {
GeomRect$draw(data, scales, coordinates, ...)
Expand Down
5 changes: 4 additions & 1 deletion R/geom-blank.r
Expand Up @@ -3,11 +3,14 @@
#' The blank geom draws nothing, but can be a useful way of ensuring common
#' scales between different plots.
#'
#' @name geom_blank
#' @export
#' @examples
#' qplot(length, rating, data=movies, geom="blank")
#' # Nothing to see here!
geom_blank <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomBlank$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomBlank <- proto(Geom, {
objname <- "blank"

Expand Down
8 changes: 7 additions & 1 deletion R/geom-boxplot.r
@@ -1,6 +1,5 @@
#' Box and whiskers plot.
#'
#' @name geom_boxplot
#' @seealso \code{\link{stat_quantile}} to view quantiles conditioned on a
#' continuous variable, \code{\link{geom_jitter}} for another way to look
#' at conditional distributions"
Expand Down Expand Up @@ -58,6 +57,13 @@
#' b + geom_boxplot(stat = "identity")
#' b + geom_boxplot(stat = "identity") + coord_flip()
#' b + geom_boxplot(aes(fill = X1), stat = "identity")
geom_boxplot <- function (mapping = NULL, data = NULL, stat = "boxplot", position = "dodge",
outlier.colour = "black", outlier.shape = 16, outlier.size = 2, ...) {
GeomBoxplot$new(mapping = mapping, data = data, stat = stat,
position = position, outlier.colour = outlier.colour, outlier.shape = outlier.shape,
outlier.size = outlier.size, ...)
}

GeomBoxplot <- proto(Geom, {
objname <- "boxplot"

Expand Down
9 changes: 7 additions & 2 deletions R/geom-crossbar.r
@@ -1,6 +1,5 @@
#' Hollow bar with middle indicated by horizontal line.
#'
#' @name geom_crossbar
#'
#' @param fatten a multiplicate factor to fatten middle bar by
#' @seealso \code{\link{geom_errorbar}} for error bars,
#' \code{\link{geom_pointrange}} and \code{\link{geom_linerange}} for other
Expand All @@ -9,6 +8,12 @@
#' @export
#' @examples
#' # See geom_linerange for examples
geom_crossbar <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
fatten = 2, ...) {
GeomCrossbar$new(mapping = mapping, data = data, stat = stat,
position = position, fatten = fatten, ...)
}

GeomCrossbar <- proto(Geom, {
objname <- "crossbar"

Expand Down
7 changes: 5 additions & 2 deletions R/geom-error.r
@@ -1,6 +1,5 @@
#' Error bars.
#'
#' @name geom_errorbar
#'
#' @seealso \code{\link{geom_pointrange}}: range indicated by straight line,
#' with point in the middle; \code{\link{geom_linerange}}: range indicated
#' by straight line; \code{\link{geom_crossbar}}: hollow bar with middle
Expand Down Expand Up @@ -41,6 +40,10 @@
#' # groups which define the lines - here the groups in the
#' # original dataframe
#' p + geom_line(aes(group=group)) + geom_errorbar(limits, width=0.2)
geom_errorbar <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomErrorbar$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomErrorbar <- proto(Geom, {
objname <- "errorbar"

Expand Down
7 changes: 5 additions & 2 deletions R/geom-errorh.r
@@ -1,6 +1,5 @@
#' Horizontal error bars
#'
#' @name geom_errorbarh
#'
#' @seealso \code{\link{geom_errorbar}}: vertical error bars
#' @param height height of errorbars
#' @export
Expand All @@ -19,6 +18,10 @@
#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se))
#' p + geom_point() +
#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se, height = .2))
geom_errorbarh <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomErrorbarh$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomErrorbarh <- proto(Geom, {
objname <- "errorbarh"

Expand Down
17 changes: 10 additions & 7 deletions R/geom-freqpoly.r
@@ -1,18 +1,21 @@
#' Frequency polygon.
#'
#' @name geom_freqpoly
#' @seealso \code{\link{geom_histogram}}: histograms
#' @export
#' @examples
#' qplot(carat, data = diamonds, geom="freqpoly")
#' qplot(carat, data = diamonds, geom="freqpoly", binwidth = 0.1)
#' qplot(carat, data = diamonds, geom="freqpoly", binwidth = 0.01)
#' qplot(carat, data = diamonds, geom = "freqpoly")
#' qplot(carat, data = diamonds, geom = "freqpoly", binwidth = 0.1)
#' qplot(carat, data = diamonds, geom = "freqpoly", binwidth = 0.01)
#'
#' qplot(price, data = diamonds, geom="freqpoly", binwidth = 1000)
#' qplot(price, data = diamonds, geom="freqpoly", binwidth = 1000,
#' qplot(price, data = diamonds, geom = "freqpoly", binwidth = 1000)
#' qplot(price, data = diamonds, geom = "freqpoly", binwidth = 1000,
#' colour = color)
#' qplot(price, ..density.., data = diamonds, geom="freqpoly",
#' qplot(price, ..density.., data = diamonds, geom = "freqpoly",
#' binwidth = 1000, colour = color)
geom_freqpoly <- function (mapping = NULL, data = NULL, stat = "bin", position = "identity", ...) {
GeomFreqpoly$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomFreqpoly <- proto(Geom, {
objname <- "freqpoly"

Expand Down
7 changes: 5 additions & 2 deletions R/geom-hex.r
@@ -1,9 +1,12 @@
#' Hexagon bining.
#'
#' @name geom_hex
#'
#' @export
#' @examples
#' # See ?stat_binhex for examples
geom_hex <- function (mapping = NULL, data = NULL, stat = "binhex", position = "identity", ...) {
GeomHex$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomHex <- proto(Geom, {
objname <- "hex"

Expand Down
5 changes: 4 additions & 1 deletion R/geom-hline.r
Expand Up @@ -10,7 +10,6 @@
#' intercept for each panel using a data.frame. See the examples for the
#' differences
#'
#' @name geom_hline
#' @seealso \code{\link{geom_vline}} for vertical lines,
#' \code{\link{geom_abline}} for lines defined by a slope and intercept,
#' \code{\link{geom_segment}} for a more general approach
Expand All @@ -28,6 +27,10 @@
#'
#' hline.data <- data.frame(z = 1:4, vs = c(0,0,1,1), am = c(0,1,0,1))
#' p + geom_hline(aes(yintercept = z), hline.data)
geom_hline <- function (mapping = NULL, data = NULL, stat = "hline", position = "identity", ...) {
GeomHline$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomHline <- proto(Geom, {
objname <- "hline"

Expand Down
5 changes: 4 additions & 1 deletion R/geom-linerange.r
@@ -1,6 +1,5 @@
#' An interval represented by a vertical line.
#'
#' @name geom_linerange
#' @seealso \code{\link{geom_errorbar}}: error bars;
#' \code{\link{geom_pointrange}}: range indicated by straight line, with
#' point in the middle; \code{\link{geom_crossbar}}: hollow bar with middle
Expand Down Expand Up @@ -28,6 +27,10 @@
#'
#' # Use coord_flip to flip the x and y axes
#' se + geom_linerange() + coord_flip()
geom_linerange <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomLinerange$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomLinerange <- proto(Geom, {
objname <- "linerange"

Expand Down
7 changes: 6 additions & 1 deletion R/geom-path-.r
@@ -1,6 +1,5 @@
#' Connect observations in original order
#'
#' @name geom_path
#' @param lineend Line end style (round, butt, square)
#' @param linejoin Line join style (round, mitre, bevel)
#' @param linemitre Line mitre limit (number greater than 1)
Expand Down Expand Up @@ -87,6 +86,12 @@
#' # Arrow defaults to "last"
#' c + geom_path(arrow = arrow())
#' c + geom_path(arrow = arrow(angle = 15, ends = "both", length = unit(0.6, "inches")))
geom_path <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
lineend = "butt", linejoin = "round", linemitre = 1, na.rm = FALSE, ...) {
GeomPath$new(mapping = mapping, data = data, stat = stat, position = position,
lineend = lineend, linejoin = linejoin, linemitre = linemitre, na.rm = na.rm, ...)
}

GeomPath <- proto(Geom, {
objname <- "path"

Expand Down
7 changes: 6 additions & 1 deletion R/geom-path-contour.r
@@ -1,10 +1,15 @@
#' Display contours of a 3d surface in 2d.
#'
#' @name geom_contour
#' @seealso \code{\link{geom_density2d}}: 2d density contours
#' @export
#' @examples
#' # See stat_contour for examples
geom_contour <- function (mapping = NULL, data = NULL, stat = "contour", position = "identity",
lineend = "butt", linejoin = "round", linemitre = 1, na.rm = FALSE, ...) {
GeomContour$new(mapping = mapping, data = data, stat = stat, position = position,
lineend = lineend, linejoin = linejoin, linemitre = linemitre, na.rm = na.rm, ...)
}

GeomContour <- proto(GeomPath, {
objname <- "contour"

Expand Down
9 changes: 7 additions & 2 deletions R/geom-path-density2d.r
Expand Up @@ -4,13 +4,18 @@
#' results with contours.
#'
#' This can be useful for dealing with overplotting.
#'
#' @name geom_density2d
#'
#' @seealso \code{\link{geom_contour}} for contour drawing geom,
#' \code{\link{stat_sum}} for another way of dealing with overplotting
#' @export
#' @examples
#' # See stat_density2d for examples
geom_density2d <- function (mapping = NULL, data = NULL, stat = "density2d", position = "identity",
lineend = "butt", linejoin = "round", linemitre = 1, na.rm = FALSE, ...) {
GeomDensity2d$new(mapping = mapping, data = data, stat = stat, position = position,
lineend = lineend, linejoin = linejoin, linemitre = linemitre, na.rm = na.rm, ...)
}

GeomDensity2d <- proto(GeomPath, {
objname <- "density2d"

Expand Down
5 changes: 4 additions & 1 deletion R/geom-path-line.r
@@ -1,6 +1,5 @@
#' Connect observations, ordered by x value.
#'
#' @name geom_line
#' @seealso \code{\link{geom_path}}: connect observations in data order,
#' \code{\link{geom_segment}}: draw line segments,
#' \code{\link{geom_ribbon}}: fill between line and x-axis
Expand Down Expand Up @@ -56,6 +55,10 @@
#' dfm <- melt(df, id.var = c("id", "group"))
#' ggplot(dfm, aes(variable, value, group = id, colour = group)) +
#' geom_path(alpha = 0.5)
geom_line <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomLine$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomLine <- proto(GeomPath, {
objname <- "line"

Expand Down
7 changes: 6 additions & 1 deletion R/geom-path-step.r
@@ -1,6 +1,5 @@
#' Connect observations by stairs.
#'
#' @name geom_step
#' @param direction direction of stairs: 'vh' for vertical then horizontal, or
#' 'hv' for horizontal then vertical
#' @export
Expand All @@ -22,6 +21,12 @@
#' trt = sample(c("a", "b"), 50, rep = T)
#' )
#' qplot(seq_along(x), x, data = df, geom="step", colour = trt)
geom_step <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
direction = "hv", ...) {
GeomStep$new(mapping = mapping, data = data, stat = stat, position = position,
direction = direction, ...)
}

GeomStep <- proto(Geom, {
objname <- "step"

Expand Down
7 changes: 6 additions & 1 deletion R/geom-point-jitter.r
Expand Up @@ -4,7 +4,6 @@
#' 'jitter'. See \code{\link{position_jitter}} to see how to adjust amount
#' of jittering.
#'
#' @name geom_jitter
#' @seealso
#' \code{\link{geom_point}} for regular, unjittered points,
#' \code{\link{geom_boxplot}} for another way of looking at the conditional
Expand All @@ -28,6 +27,12 @@
#' qplot(mpaa, rating, data=movies, geom="jitter")
#' qplot(mpaa, rating, data=movies, geom=c("boxplot","jitter"))
#' qplot(mpaa, rating, data=movies, geom=c("jitter", "boxplot"))
geom_jitter <- function (mapping = NULL, data = NULL, stat = "identity", position = "jitter",
na.rm = FALSE, ...) {
GeomJitter$new(mapping = mapping, data = data, stat = stat, position = position,
na.rm = na.rm, ...)
}

GeomJitter <- proto(GeomPoint, {
objname <- "jitter"

Expand Down
5 changes: 4 additions & 1 deletion R/geom-pointrange.r
@@ -1,6 +1,5 @@
#' An interval represented by a vertical line, with a point in the middle.
#'
#' @name geom_pointrange
#' @seealso
#' \code{\link{geom_errorbar}} for error bars,
#' \code{\link{geom_linerange}} for range indicated by straight line, + examples,
Expand All @@ -10,6 +9,10 @@
#' @export
#' @examples
#' # See geom_linerange for examples
geom_pointrange <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomPointrange$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}

GeomPointrange <- proto(Geom, {
objname <- "pointrange"

Expand Down

0 comments on commit ede677c

Please sign in to comment.