Skip to content
Browse files

Better documentation for facets

  • Loading branch information...
1 parent a0394ef commit 9d3d8e876eb0f5216a2b92b616471d5b47ad90b4 @hadley committed Dec 19, 2011
Showing with 90 additions and 8 deletions.
  1. +19 −1 R/facet-grid-.r
  2. +4 −0 R/facet-labels.r
  3. +1 −0 R/facet-null.r
  4. +5 −3 R/facet-wrap.r
  5. +29 −1 man/facet_grid.Rd
  6. +5 −0 man/facet_null.Rd
  7. +13 −3 man/facet_wrap.Rd
  8. +4 −0 man/label_both.Rd
  9. +3 −0 man/label_bquote.Rd
  10. +3 −0 man/label_parsed.Rd
  11. +4 −0 man/label_value.Rd
View
20 R/facet-grid-.r
@@ -5,7 +5,25 @@
#' formula is used to indicate there should be no faceting on this dimension
#' (either row or column). The formula can also be provided as a string
#' instead of a classical formula object
-#' @param margin logical value, should marginal rows and columns be displayed
+#' @param margins logical value, should marginal rows and columns be displayed
+#' @param scales Are scales shared across all facets (the default,
+#' \code{"fixed"}), or do they vary across rows (\code{"free_x"}),
+#' columns (\code{"free_y"}), or both rows and columns (\code{"free"})
+#' @param space If \code{"fixed"}, the default, all panels have the same size.
+#' If \code{"free_y"} their height will be proportional to the length of the
+#' y scale; if \code{"free_x"} their width will be proportional to the
+#' length of the x scale; or if \code{"free"} both height and width will
+#' vary. This setting has no effect unless the appropriate scales also vary.
+#' @param labeller A function that takes two arguments (\code{variable} and
+#' \code{value}) and returns a string suitable for display in the facet
+#' strip. See \code{\link{label_value}} for more details and pointers
+#' to other options.
+#' @param as.table If \code{TRUE}, the default, the facets are laid out like
+#' a table with highest values at the bottom-right. If \code{FALSE}, the
+#' facet are laid out like a plot with the highest value at the top-right.
+#' @param shrink If \code{TRUE}, will shrink scales to fit output of
+#' statistics, not raw data. If \code{FALSE}, will be range of raw data
+#' before statistical summary.
#' @export
#' @examples
#' # faceting displays subsets of the data in different panels
View
4 R/facet-labels.r
@@ -3,6 +3,7 @@
#'
#' @param variable variable name passed in by facetter
#' @param value variable value passed in by facetter
+#' @family facet labellers
#' @export
#' @examples
#' p <- qplot(wt, mpg, data = mtcars)
@@ -14,6 +15,7 @@ label_value <- function(variable, value) as.character(value)
#'
#' @param variable variable name passed in by facetter
#' @param value variable value passed in by facetter
+#' @family facet labellers
#' @export
#' @examples
#' p <- qplot(wt, mpg, data = mtcars)
@@ -26,6 +28,7 @@ label_both <- function(variable, value) paste(variable, value, sep = ": ")
#' @seealso \code{\link{plotmath}}
#' @param variable variable name passed in by facetter
#' @param value variable value passed in by facetter
+#' @family facet labellers
#' @export
#' @examples
#' mtcars$cyl2 <- factor(mtcars$cyl, labels = c("alpha", "beta", "gamma"))
@@ -42,6 +45,7 @@ label_parsed <- function(variable, value) {
#' label value is x.
#'
#' @param expr labelling expression to use
+#' @family facet labellers
#' @seealso \code{\link{plotmath}}
#' @export
#' @examples
View
1 R/facet-null.r
@@ -1,5 +1,6 @@
#' Facet specification: a single panel.
#'
+#' @inheritParams facet_grid
#' @export
#' @examples
#' # facet_null is the default facetting specification if you
View
8 R/facet-wrap.r
@@ -2,9 +2,11 @@
#'
#' @param nrow number of rows
#' @param ncol number of columns
-#' @param facet formula specifying variables to facet by
-#' @param scales should scales be fixed, free, or free in one dimension
-#' (\code{free_x}, \code{free_y})
+#' @param facets formula specifying variables to facet by
+#' @param scales should scales be fixed (\code{"fixed"}, the default),
+#' free (\code{"free"}), or free in one dimension (\code{"free_x"},
+#' \code{"free_y"})
+#' @inheritParams facet_grid
#' @export
#' @examples
#' d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
View
30 man/facet_grid.Rd
@@ -14,8 +14,36 @@
(either row or column). The formula can also be provided
as a string instead of a classical formula object}
- \item{margin}{logical value, should marginal rows and
+ \item{margins}{logical value, should marginal rows and
columns be displayed}
+
+ \item{scales}{Are scales shared across all facets (the
+ default, \code{"fixed"}), or do they vary across rows
+ (\code{"free_x"}), columns (\code{"free_y"}), or both
+ rows and columns (\code{"free"})}
+
+ \item{space}{If \code{"fixed"}, the default, all panels
+ have the same size. If \code{"free_y"} their height will
+ be proportional to the length of the y scale; if
+ \code{"free_x"} their width will be proportional to the
+ length of the x scale; or if \code{"free"} both height
+ and width will vary. This setting has no effect unless
+ the appropriate scales also vary.}
+
+ \item{labeller}{A function that takes two arguments
+ (\code{variable} and \code{value}) and returns a string
+ suitable for display in the facet strip. See
+ \code{\link{label_value}} for more details and pointers
+ to other options.}
+
+ \item{as.table}{If \code{TRUE}, the default, the facets
+ are laid out like a table with highest values at the
+ bottom-right. If \code{FALSE}, the facet are laid out
+ like a plot with the highest value at the top-right.}
+
+ \item{shrink}{If \code{TRUE}, will shrink scales to fit
+ output of statistics, not raw data. If \code{FALSE}, will
+ be range of raw data before statistical summary.}
}
\description{
Lay out panels in a grid.
View
5 man/facet_null.Rd
@@ -4,6 +4,11 @@
\usage{
facet_null(shrink = TRUE)
}
+\arguments{
+ \item{shrink}{If \code{TRUE}, will shrink scales to fit
+ output of statistics, not raw data. If \code{FALSE}, will
+ be range of raw data before statistical summary.}
+}
\description{
Facet specification: a single panel.
}
View
16 man/facet_wrap.Rd
@@ -10,10 +10,20 @@
\item{ncol}{number of columns}
- \item{facet}{formula specifying variables to facet by}
+ \item{facets}{formula specifying variables to facet by}
- \item{scales}{should scales be fixed, free, or free in
- one dimension (\code{free_x}, \code{free_y})}
+ \item{scales}{should scales be fixed (\code{"fixed"}, the
+ default), free (\code{"free"}), or free in one dimension
+ (\code{"free_x"}, \code{"free_y"})}
+
+ \item{shrink}{If \code{TRUE}, will shrink scales to fit
+ output of statistics, not raw data. If \code{FALSE}, will
+ be range of raw data before statistical summary.}
+
+ \item{as.table}{If \code{TRUE}, the default, the facets
+ are laid out like a table with highest values at the
+ bottom-right. If \code{FALSE}, the facet are laid out
+ like a plot with the highest value at the top-right.}
}
\description{
Wrap a 1d ribbon of panels into 2d.
View
4 man/label_both.Rd
@@ -17,4 +17,8 @@ p <- qplot(wt, mpg, data = mtcars)
p + facet_grid(. ~ cyl)
p + facet_grid(. ~ cyl, labeller = label_both)
}
+\seealso{
+ Other facet labellers: \code{\link{label_bquote}},
+ \code{\link{label_parsed}}, \code{\link{label_value}}
+}
View
3 man/label_bquote.Rd
@@ -18,5 +18,8 @@ p + facet_grid(. ~ vs, labeller = label_bquote(.(x) ^ .(x)))
}
\seealso{
\code{\link{plotmath}}
+
+ Other facet labellers: \code{\link{label_both}},
+ \code{\link{label_parsed}}, \code{\link{label_value}}
}
View
3 man/label_parsed.Rd
@@ -20,5 +20,8 @@ qplot(wt, mpg, data = mtcars) + facet_grid(. ~ cyl2,
}
\seealso{
\code{\link{plotmath}}
+
+ Other facet labellers: \code{\link{label_both}},
+ \code{\link{label_bquote}}, \code{\link{label_value}}
}
View
4 man/label_value.Rd
@@ -19,4 +19,8 @@ p <- qplot(wt, mpg, data = mtcars)
p + facet_grid(. ~ cyl)
p + facet_grid(. ~ cyl, labeller = label_value)
}
+\seealso{
+ Other facet labellers: \code{\link{label_both}},
+ \code{\link{label_bquote}}, \code{\link{label_parsed}}
+}

0 comments on commit 9d3d8e8

Please sign in to comment.
Something went wrong with that request. Please try again.