Skip to content

Commit f9b388c

Browse files
committed
stat-summary-2d/hex: update documents.
1 parent 3f7727d commit f9b388c

File tree

5 files changed

+124
-35
lines changed

5 files changed

+124
-35
lines changed

NAMESPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ export(scale_y_reverse)
159159
export(scale_y_sqrt)
160160
export(should_stop)
161161
export(stat_abline)
162-
export(stat_summary2d)
163-
export(stat_summary_hex)
164162
export(stat_bin)
165163
export(stat_bin2d)
166164
export(stat_binhex)
@@ -176,7 +174,9 @@ export(stat_quantile)
176174
export(stat_smooth)
177175
export(stat_spoke)
178176
export(stat_sum)
177+
export(stat_summary_hex)
179178
export(stat_summary)
179+
export(stat_summary2d)
180180
export(stat_unique)
181181
export(stat_vline)
182182
export(theme_blank)

R/stat-summary-2d.r

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1-
#' Apply function for rectangular bins.
2-
#'
3-
#' @seealso \code{\link{stat_summary_hex}} for hexagonal summarization. \code{\link{stat_bin2d}} for the binning options.
4-
#' @export
5-
#' @examples
6-
#' d <- ggplot(diamonds, aes(carat, depth, z = price))
7-
#' d + stat_summary2d()
8-
#'
9-
#' # Specifying function
10-
#' d + stat_summary2d(fun = function(x) sum(x^2))
11-
#' d + stat_summary2d(fun = var)
1+
##' Apply function for 2D rectangular bins.
2+
##'
3+
##' \code{stat_summary2d} is 2D version of \code{\link{stat_summary}}. The data are devided by \code{x} and \code{y}.
4+
##' \code{z} in each cell is passed to arbitral summary function.
5+
##'
6+
##' \code{stat_summary2d} requires the following aesthetics:
7+
##'
8+
##' \itemize{
9+
##' \item \code{x}: horizontal position
10+
##' \item \code{y}: vertical position
11+
##' \item \code{z}: value passed to the summary function
12+
##' }
13+
##'
14+
##' @seealso \code{\link{stat_summary_hex}} for hexagonal summarization. \code{\link{stat_bin2d}} for the binning options.
15+
##' @title Apply funciton for 2D rectangular bins.
16+
##' @param mapping
17+
##' @param data
18+
##' @param geom
19+
##' @param position
20+
##' @param bins see \code{\link{stat_bin2d}}
21+
##' @param drop drop if the output of \code{fun} is \code{NA}.
22+
##' @param fun function for summary.
23+
##' @param ... parameters passed to \code{fun}
24+
##' @export
25+
##' @examples
26+
##' d <- ggplot(diamonds, aes(carat, depth, z = price))
27+
##' d + stat_summary2d()
28+
##'
29+
##' # Specifying function
30+
##' d + stat_summary2d(fun = function(x) sum(x^2))
31+
##' d + stat_summary2d(fun = var)
1232
stat_summary2d <- function (mapping = NULL, data = NULL, geom = NULL, position = "identity",
1333
bins = 30, drop = TRUE, fun = mean, ...) {
1434

R/stat-summary-hex.r

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
1-
#' Apply functions to hexagonal bins.
2-
#'
3-
#' @seealso \code{\link{stat_summary2d}} for rectangular summarization. \code{\link{stat_bin2d}} for the hexagon-ing options.
4-
#' @export
5-
#' @examples
6-
#' d <- ggplot(diamonds, aes(carat, price))
7-
#' d + stat_summary_hex()
8-
#'
9-
#' # Specifying function
10-
#' d + stat_summary_hex(fun = function(x) sum(x^2))
11-
#' d + stat_summary_hex(fun = var, na.rm = T)
1+
##' Apply function for 2D hexagonal bins.
2+
##'
3+
##' \code{stat_summary2d} is hexagonal version of \code{\link{stat_summary}}. The data are devided by \code{x} and \code{y}.
4+
##' \code{z} in each cell is passed to arbitral summary function.
5+
##'
6+
##' \code{stat_summary-hex} requires the following aesthetics:
7+
##'
8+
##' \itemize{
9+
##' \item \code{x}: horizontal position
10+
##' \item \code{y}: vertical position
11+
##' \item \code{z}: value passed to the summary function
12+
##' }
13+
##'
14+
##' @seealso \code{\link{stat_summary2d}} for rectangular summarization. \code{\link{stat_bin2d}} for the hexagon-ing options.
15+
##' @title Apply funciton for 2D hexagonal bins.
16+
##' @param bins see \code{\link{stat_binhex}}
17+
##' @param drop drop if the output of \code{fun} is \code{NA}.
18+
##' @param fun function for summary.
19+
##' @param ... parameters passed to \code{fun}
20+
##' @export
21+
##' @examples
22+
##' d <- ggplot(diamonds, aes(carat, depth, z = price))
23+
##' d + stat_summary_hex()
24+
##'
25+
##' # Specifying function
26+
##' d + stat_summary_hex(fun = function(x) sum(x^2))
27+
##' d + stat_summary_hex(fun = var, na.rm = T)
1228
stat_summary_hex <- function (mapping = NULL, data = NULL, geom = "hex", position = "identity",
1329
bins = 30, drop = TRUE, fun = mean, ...) {
1430

man/stat_summary2d.Rd

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,43 @@
11
\name{stat_summary2d}
22
\alias{stat_summary2d}
3-
\title{Apply function for rectangular bins.}
3+
\title{Apply funciton for 2D rectangular bins.}
44
\usage{
5-
stat_summary2d(mapping = NULL, data = NULL, geom =
6-
"rect", position = "identity", bins = 30, drop = TRUE,
7-
fun = mean, ...)
5+
stat_summary2d(mapping = NULL, data = NULL, geom = NULL,
6+
position = "identity", bins = 30, drop = TRUE,
7+
fun = mean, ...)
8+
}
9+
\arguments{
10+
\item{mapping}{}
11+
12+
\item{data}{}
13+
14+
\item{geom}{}
15+
16+
\item{position}{}
17+
18+
\item{bins}{see \code{\link{stat_bin2d}}}
19+
20+
\item{drop}{drop if the output of \code{fun} is
21+
\code{NA}.}
22+
23+
\item{fun}{function for summary.}
24+
25+
\item{...}{parameters passed to \code{fun}}
826
}
927
\description{
10-
Apply function for rectangular bins.
28+
Apply function for 2D rectangular bins.
29+
}
30+
\details{
31+
\code{stat_summary2d} is 2D version of
32+
\code{\link{stat_summary}}. The data are devided by
33+
\code{x} and \code{y}. \code{z} in each cell is passed to
34+
arbitral summary function.
35+
36+
\code{stat_summary2d} requires the following aesthetics:
37+
38+
\itemize{ \item \code{x}: horizontal position \item
39+
\code{y}: vertical position \item \code{z}: value passed
40+
to the summary function }
1141
}
1242
\examples{
1343
d <- ggplot(diamonds, aes(carat, depth, z = price))

man/stat_summary_hex.Rd

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
11
\name{stat_summary_hex}
22
\alias{stat_summary_hex}
3-
\title{Apply functions to hexagonal bins.}
3+
\title{Apply funciton for 2D hexagonal bins.}
44
\usage{
5-
stat_summary_hex(mapping = NULL, data = NULL, geom =
6-
"hex", position = "identity", bins = 30, na.rm = FALSE,
7-
fun = mean, ...)
5+
stat_summary_hex(mapping = NULL, data = NULL,
6+
geom = "hex", position = "identity", bins = 30,
7+
drop = TRUE, fun = mean, ...)
8+
}
9+
\arguments{
10+
\item{bins}{see \code{\link{stat_binhex}}}
11+
12+
\item{drop}{drop if the output of \code{fun} is
13+
\code{NA}.}
14+
15+
\item{fun}{function for summary.}
16+
17+
\item{...}{parameters passed to \code{fun}}
818
}
919
\description{
10-
Apply functions to hexagonal bins.
20+
Apply function for 2D hexagonal bins.
21+
}
22+
\details{
23+
\code{stat_summary2d} is hexagonal version of
24+
\code{\link{stat_summary}}. The data are devided by
25+
\code{x} and \code{y}. \code{z} in each cell is passed to
26+
arbitral summary function.
27+
28+
\code{stat_summary-hex} requires the following
29+
aesthetics:
30+
31+
\itemize{ \item \code{x}: horizontal position \item
32+
\code{y}: vertical position \item \code{z}: value passed
33+
to the summary function }
1134
}
1235
\examples{
13-
d <- ggplot(diamonds, aes(carat, price))
36+
d <- ggplot(diamonds, aes(carat, depth, z = price))
1437
d + stat_summary_hex()
1538

1639
# Specifying function

0 commit comments

Comments
 (0)