Skip to content

Commit 80794d8

Browse files
committed
Rebased and documented with devel roxygen2.
1 parent 85f351c commit 80794d8

File tree

211 files changed

+1206
-954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+1206
-954
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"path" : "C:/Users/STME/GitHub/ggplot2/R",
3+
"sortOrder" : [
4+
{
5+
"ascending" : true,
6+
"columnIndex" : 2
7+
}
8+
]
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"activeTab" : 0
3+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"left" : {
3+
"panelheight" : 959,
4+
"splitterpos" : 398,
5+
"topwindowstate" : "NORMAL",
6+
"windowheight" : 997
7+
},
8+
"right" : {
9+
"panelheight" : 959,
10+
"splitterpos" : 598,
11+
"topwindowstate" : "NORMAL",
12+
"windowheight" : 997
13+
}
14+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"TabSet1" : 0,
3+
"TabSet2" : 1
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"contents" : "#' Label facets with their value.\n#' This is the default labelling scheme.\n#' \n#' @param variable variable name passed in by facetter\n#' @param value variable value passed in by facetter\n#' @family facet labellers\n#' @export\n#' @examples\n#' p <- qplot(wt, mpg, data = mtcars)\n#' p + facet_grid(. ~ cyl)\n#' p + facet_grid(. ~ cyl, labeller = label_value)\nlabel_value <- function(variable, value) as.character(value)\n\n#' Label facets with value and variable.\n#' \n#' @param variable variable name passed in by facetter\n#' @param value variable value passed in by facetter\n#' @family facet labellers\n#' @export\n#' @examples\n#' p <- qplot(wt, mpg, data = mtcars)\n#' p + facet_grid(. ~ cyl)\n#' p + facet_grid(. ~ cyl, labeller = label_both)\nlabel_both <- function(variable, value) paste(variable, value, sep = \": \")\n\n#' Label facets with parsed label.\n#' \n#' @seealso \\code{\\link{plotmath}}\n#' @param variable variable name passed in by facetter\n#' @param value variable value passed in by facetter\n#' @family facet labellers\n#' @export\n#' @examples\n#' mtcars$cyl2 <- factor(mtcars$cyl, labels = c(\"alpha\", \"beta\", \"gamma\"))\n#' qplot(wt, mpg, data = mtcars) + facet_grid(. ~ cyl2)\n#' qplot(wt, mpg, data = mtcars) + facet_grid(. ~ cyl2, \n#' labeller = label_parsed)\nlabel_parsed <- function(variable, value) {\n llply(as.character(value), function(x) parse(text = x))\n}\n\n#' Label facet with 'bquoted' expressions\n#' \n#' See \\code{\\link{bquote}} for details on the syntax of the argument. The\n#' label value is x. \n#' \n#' @param expr labelling expression to use\n#' @family facet labellers\n#' @seealso \\code{\\link{plotmath}}\n#' @export\n#' @examples\n#' p <- qplot(wt, mpg, data = mtcars)\n#' p + facet_grid(. ~ vs, labeller = label_bquote(alpha ^ .(x)))\n#' p + facet_grid(. ~ vs, labeller = label_bquote(.(x) ^ .(x)))\nlabel_bquote <- function(expr = beta ^ .(x)) {\n quoted <- substitute(expr)\n \n function(variable, value) {\n value <- as.character(value)\n lapply(value, function(x)\n eval(substitute(bquote(expr, list(x = x)), list(expr = quoted))))\n }\n}\n\n#' Label facets with a word wrapped label.\n#' \n#' Uses \\code{\\link[base]{strwrap}} for line wrapping.\n#' @param width integer, target column width for output.\n#' @export\n#' @seealso , \\code{\\link{labeller}}\n#' @examples\n#' set.seed(331)\n#' x=runif(60)\n#' y=rnorm(60)\n#' speed=sample(c('Prime group', 'Rib group', 'No group'), 60, replace=TRUE)\n#' group=sample(letters[1:3], 60, replace=TRUE)\n#' \n#' df = data.frame(x=x, y=y, speed=as.factor(speed), group=as.factor(group))\n#' group.names <- c('a'='First','b'='Second','c'=\"Don\\'t\")\n#' \n#' ggplot(df, aes(x, y)) + geom_point() + facet_grid(speed ~ group, labeller=label_wrap_gen(3))\n#' ggplot(df, aes(x, y)) + geom_point() + facet_grid(speed ~ group, labeller=labeller(speed=label_wrap_gen(3), group=group.names))\nlabel_wrap_gen <- function(width = 25) {\n function(variable, value) {\n lapply(strwrap(as.character(value), width=width, simplify=FALSE), \n paste, collapse=\"\\n\")\n }\n}\n\n#' Generic labeller function for facets\n#' \n#' One-step function for providing methods or named character vectors\n#' as labels in facets.\n#'\n#' @param keep.as.numbers logical, default TRUE. When FALSE, converts numeric values supplied as margins to the facet to characters.\n#' @family facet labeller\n#' @return Function to supply to \\code{\\link{facet_grid}} for the argument \\code{labeller}.\n#' @export \n#' @examples\n#' numbers <- c(`4`='four', `6`='six', `8`='eight')\n#' vs <- c(`0`='No vs', `1`='vs')\n#' p <- ggplot(mtcars, aes(mpg, wt)) + geom_point()\n#' p + facet_grid(vs~cyl, labeller=labeller(cyl=numbers, vs=vs))\nlabeller <- function(keep.as.numeric=FALSE, ...) {\n args <- list(...)\n lbl <- function(variable, values) {\n res <- args[[variable]]\n if (is.numeric(values) & !keep.as.numeric) values <- as.character(values)\n #print(str(variable))\n #print(str(values))\n \n if (is.null(res)) {\n if (is.factor(values)) return(levels(values[drop=TRUE]))\n return(values)\n }\n if (is.function(res)) return(res(variable, values))\n if (is.logical(values)) values <- as.integer(values)+1\n if (is.factor(values)) values <- levels(values)[values]\n return(res[values])\n }\n return(lbl)\n}\n\n\n\n# Grob for strip labels\nggstrip <- function(text, horizontal=TRUE, theme) {\n text_theme <- if (horizontal) \"strip.text.x\" else \"strip.text.y\"\n if (is.list(text)) text <- text[[1]]\n\n label <- element_render(theme, text_theme, text)\n\n ggname(\"strip\", absoluteGrob(\n gList(\n element_render(theme, \"strip.background\"),\n label\n ),\n width = grobWidth(label) + unit(0.5, \"lines\"),\n height = grobHeight(label) + unit(0.5, \"lines\")\n ))\n}\n",
3+
"created" : 1391521489199.000,
4+
"dirty" : false,
5+
"encoding" : "UTF-8",
6+
"folds" : "",
7+
"hash" : "3399979365",
8+
"id" : "D86377F7",
9+
"lastKnownWriteTime" : 1391522077,
10+
"path" : "C:/Users/STME/GitHub/ggplot2/R/facet-labels.r",
11+
"project_path" : "R/facet-labels.r",
12+
"properties" : {
13+
},
14+
"source_on_save" : false,
15+
"type" : "r_source"
16+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

.Rproj.user/8FAC18A5/sdb/prop/INDEX

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C%3A%2FUsers%2FSTME%2FGitHub%2Fggplot2%2FR%2Ffacet-labels.r="84E407BA"

NAMESPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Generated by roxygen2 (4.0.0): do not edit by hand
2+
13
S3method("+",gg)
24
S3method("[",uneval)
35
S3method(as.character,uneval)
@@ -270,6 +272,8 @@ export(label_both)
270272
export(label_bquote)
271273
export(label_parsed)
272274
export(label_value)
275+
export(label_wrap_gen)
276+
export(labeller)
273277
export(labs)
274278
export(last_plot)
275279
export(layer)

R i386 3.0.2.lnk

1.11 KB
Binary file not shown.

ggplot2.Rproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: Default
4+
SaveWorkspace: Default
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: knitr
13+
LaTeX: pdfLaTeX
14+
15+
BuildType: Package
16+
PackageInstallArgs: --no-multiarch --with-keep.source

man/absoluteGrob.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{absoluteGrob}
23
\alias{absoluteGrob}
34
\title{Absolute grob}

man/add_theme.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{add_theme}
23
\alias{add_theme}
34
\title{Modify properties of an element in a theme object}

man/aes.Rd

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{aes}
23
\alias{aes}
34
\title{Generate aesthetic mappings that describe how variables in the data are
@@ -14,21 +15,18 @@ aes(x, y, ...)
1415
map.}
1516
}
1617
\description{
17-
\code{aes} creates a list of unevaluated expressions. This
18-
function also performs partial name matching, converts
19-
color to colour, and old style R names to ggplot names (eg.
20-
pch to shape, cex to size)
18+
\code{aes} creates a list of unevaluated expressions. This function also
19+
performs partial name matching, converts color to colour, and old style R
20+
names to ggplot names (eg. pch to shape, cex to size)
2121
}
2222
\examples{
2323
aes(x = mpg, y = wt)
2424
aes(x = mpg ^ 2, y = wt / cyl)
2525
}
2626
\seealso{
2727
\code{\link{aes_string}} for passing quoted variable names.
28-
\code{\link{aes_colour_fill_alpha}},
29-
\code{\link{aes_group_order}},
30-
\code{\link{aes_linetype_size_shape}} and
31-
\code{\link{aes_position}} for more specific examples with
32-
different aesthetics.
28+
\code{\link{aes_colour_fill_alpha}}, \code{\link{aes_group_order}},
29+
\code{\link{aes_linetype_size_shape}} and \code{\link{aes_position}}
30+
for more specific examples with different aesthetics.
3331
}
3432

man/aes_all.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{aes_all}
23
\alias{aes_all}
34
\title{Given a character vector, create a set of identity mappings}

man/aes_auto.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{aes_auto}
23
\alias{aes_auto}
34
\title{Automatic aesthetic mapping}

man/aes_colour_fill_alpha.Rd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{aes_colour_fill_alpha}
23
\alias{aes_colour_fill_alpha}
34
\alias{alpha}
@@ -6,8 +7,8 @@
67
\alias{fill}
78
\title{Colour related aesthetics: colour, fill and alpha}
89
\description{
9-
This page demonstrates the usage of a sub-group of
10-
aesthetics; colour, fill and alpha.
10+
This page demonstrates the usage of a sub-group
11+
of aesthetics; colour, fill and alpha.
1112
}
1213
\examples{
1314
\donttest{

man/aes_group_order.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{aes_group_order}
23
\alias{aes_group_order}
34
\alias{group}

man/aes_linetype_size_shape.Rd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{aes_linetype_size_shape}
23
\alias{aes_linetype_size_shape}
34
\alias{linetype}
45
\alias{shape}
56
\alias{size}
67
\title{Differentiation related aesthetics: linetype, size, shape}
78
\description{
8-
This page demonstrates the usage of a sub-group of
9-
aesthetics; linetype, size and shape.
9+
This page demonstrates the usage of a sub-group
10+
of aesthetics; linetype, size and shape.
1011
}
1112
\examples{
1213
# Line types should be specified with either an integer, a name, or with a string of

man/aes_position.Rd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{aes_position}
23
\alias{aes_position}
34
\alias{x}
@@ -10,8 +11,8 @@
1011
\alias{ymin}
1112
\title{Position related aesthetics: x, y, xmin, xmax, ymin, ymax, xend, yend}
1213
\description{
13-
This page demonstrates the usage of a sub-group of
14-
aesthetics; x, y, xmin, xmax, ymin, ymax, xend, and yend.
14+
This page demonstrates the usage of a sub-group
15+
of aesthetics; x, y, xmin, xmax, ymin, ymax, xend, and yend.
1516
}
1617
\examples{
1718
# Generate data: means and standard errors of means for prices

man/aes_string.Rd

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{aes_string}
23
\alias{aes_string}
34
\title{Generate aesthetic mappings from a string}
@@ -8,16 +9,14 @@ aes_string(...)
89
\item{...}{List of name value pairs}
910
}
1011
\description{
11-
Aesthetic mappings describe how variables in the data are
12-
mapped to visual properties (aesthetics) of geoms.
13-
Compared to aes this function operates on strings rather
14-
than expressions.
12+
Aesthetic mappings describe how variables in the data are mapped to visual
13+
properties (aesthetics) of geoms. Compared to aes this function operates
14+
on strings rather than expressions.
1515
}
1616
\details{
17-
\code{aes_string} is particularly useful when writing
18-
functions that create plots because you can use strings to
19-
define the aesthetic mappings, rather than having to mess
20-
around with expressions.
17+
\code{aes_string} is particularly useful when writing functions that create
18+
plots because you can use strings to define the aesthetic mappings, rather
19+
than having to mess around with expressions.
2120
}
2221
\examples{
2322
aes_string(x = "mpg", y = "wt")

man/annotate.Rd

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{annotate}
23
\alias{annotate}
34
\title{Create an annotation layer.}
@@ -15,18 +16,17 @@ annotate(geom, x = NULL, y = NULL, xmin = NULL, xmax = NULL,
1516
can do (e.g.) \code{colour = "red"} to get a red point.}
1617
}
1718
\description{
18-
This function adds geoms to a plot. Unlike typical a geom
19-
function, the properties of the geoms are not mapped from
20-
variables of a data frame, but are instead in as vectors.
21-
This is useful for adding small annotations (such as text
22-
labels) or if you have your data in vectors, and for some
19+
This function adds geoms to a plot. Unlike typical a geom function,
20+
the properties of the geoms are not mapped from variables of a data frame,
21+
but are instead in as vectors. This is useful for adding small annotations
22+
(such as text labels) or if you have your data in vectors, and for some
2323
reason don't want to put them in a data frame.
2424
}
2525
\details{
26-
Note that all position aesthetics are scaled (i.e. they
27-
will expand the limits of the plot so they are visible),
28-
but all other aesthetics are set. This means that layers
29-
created with this function will never affect the legend.
26+
Note that all position aesthetics are scaled (i.e. they will expand the
27+
limits of the plot so they are visible), but all other aesthetics are
28+
set. This means that layers created with this function will never
29+
affect the legend.
3030
}
3131
\examples{
3232
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()

man/annotation_custom.Rd

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{annotation_custom}
23
\alias{annotation_custom}
34
\title{Annotation: Custom grob.}
@@ -15,22 +16,19 @@ annotation_custom(grob, xmin = -Inf, xmax = Inf, ymin = -Inf,
1516
vertical location of raster}
1617
}
1718
\description{
18-
This is a special geom intended for use as static
19-
annnotations that are the same in every panel. These
20-
anotations will not affect scales (i.e. the x and y axes
21-
will not grow to cover the range of the grob, and the grob
22-
will not be modified by any ggplot settings or mappings).
19+
This is a special geom intended for use as static annnotations
20+
that are the same in every panel. These anotations will not
21+
affect scales (i.e. the x and y axes will not grow to cover the range
22+
of the grob, and the grob will not be modified by any ggplot settings or mappings).
2323
}
2424
\details{
25-
Most useful for adding tables, inset plots, and other
26-
grid-based decorations.
25+
Most useful for adding tables, inset plots, and other grid-based decorations.
2726
}
2827
\note{
29-
\code{annotation_custom} expects the grob to fill the
30-
entire viewport defined by xmin, xmax, ymin, ymax. Grobs
31-
with a different (absolute) size will be center-justified
32-
in that region. Inf values can be used to fill the full
33-
plot panel (see examples).
28+
\code{annotation_custom} expects the grob to fill the entire viewport
29+
defined by xmin, xmax, ymin, ymax. Grobs with a different (absolute) size
30+
will be center-justified in that region.
31+
Inf values can be used to fill the full plot panel (see examples).
3432
}
3533
\examples{
3634
# Dummy plot

man/annotation_logticks.Rd

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{annotation_logticks}
23
\alias{annotation_logticks}
34
\title{Annotation: log tick marks}
@@ -46,9 +47,8 @@ annotation_logticks(base = 10, sides = "bl", scaled = TRUE,
4647
\item{...}{Other parameters passed on to the layer}
4748
}
4849
\description{
49-
This annotation adds log tick marks with diminishing
50-
spacing. These tick marks probably make sense only for base
51-
10.
50+
This annotation adds log tick marks with diminishing spacing.
51+
These tick marks probably make sense only for base 10.
5252
}
5353
\examples{
5454
# Make a log-log plot (without log ticks)
@@ -97,10 +97,9 @@ library(grid)
9797
a + annotation_logticks(short = unit(.5,"mm"), mid = unit(3,"mm"), long = unit(4,"mm"))
9898
}
9999
\seealso{
100-
\code{\link{scale_y_continuous}},
101-
\code{\link{scale_y_log10}} for log scale transformations.
100+
\code{\link{scale_y_continuous}}, \code{\link{scale_y_log10}} for log scale
101+
transformations.
102102

103-
\code{\link{coord_trans}} for log coordinate
104-
transformations.
103+
\code{\link{coord_trans}} for log coordinate transformations.
105104
}
106105

man/annotation_map.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{annotation_map}
23
\alias{annotation_map}
34
\title{Annotation: maps.}

man/annotation_raster.Rd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{annotation_raster}
23
\alias{annotation_raster}
34
\title{Annotation: High-performance rectangular tiling.}
@@ -17,11 +18,10 @@ annotation_raster(raster, xmin, xmax, ymin, ymax, interpolate = FALSE)
1718
if \code{FALSE} (the default) don't interpolate.}
1819
}
1920
\description{
20-
This is a special version of \code{\link{geom_raster}}
21-
optimised for static annotations that are the same in every
22-
panel. These annotations will not affect scales (i.e. the x
23-
and y axes will not grow to cover the range of the raster,
24-
and the raster must already have its own colours).
21+
This is a special version of \code{\link{geom_raster}} optimised for static
22+
annotations that are the same in every panel. These annotations will not
23+
affect scales (i.e. the x and y axes will not grow to cover the range
24+
of the raster, and the raster must already have its own colours).
2525
}
2626
\details{
2727
Most useful for adding bitmap images.

man/autoplot.Rd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{autoplot}
23
\alias{autoplot}
34
\title{Create a complete ggplot appropriate to a particular data type}
@@ -14,10 +15,9 @@ autoplot(object, ...)
1415
a ggplot object
1516
}
1617
\description{
17-
\code{autoplot} uses ggplot2 to draw a particular plot for
18-
an object of a particular class in a single command. This
19-
defines the S3 generic that other classes and packages can
20-
extend.
18+
\code{autoplot} uses ggplot2 to draw a particular plot for an object of a
19+
particular class in a single command. This defines the S3 generic that
20+
other classes and packages can extend.
2121
}
2222
\seealso{
2323
\code{\link{ggplot}} and \code{\link{fortify}}

man/benchplot.Rd

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{benchplot}
23
\alias{benchplot}
34
\title{Benchmark plot creation time.
@@ -9,8 +10,8 @@ benchplot(x)
910
\item{x}{code to create ggplot2 plot}
1011
}
1112
\description{
12-
Benchmark plot creation time. Broken down into construct,
13-
build, render and draw times.
13+
Benchmark plot creation time.
14+
Broken down into construct, build, render and draw times.
1415
}
1516
\examples{
1617
benchplot(qplot(mpg, wt, data = mtcars))

man/borders.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
% Generated by roxygen2 (4.0.0): do not edit by hand
12
\name{borders}
23
\alias{borders}
34
\title{Create a layer of map borders.}

0 commit comments

Comments
 (0)