forked from tidyverse/dplyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsummarise.Rd
68 lines (56 loc) · 1.85 KB
/
summarise.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/manip.r
\name{summarise}
\alias{summarise}
\alias{summarise_}
\alias{summarize}
\alias{summarize_}
\title{Summarise multiple values to a single value.}
\usage{
summarise(.data, ...)
summarise_(.data, ..., .dots)
summarize(.data, ...)
summarize_(.data, ..., .dots)
}
\arguments{
\item{.data}{A tbl. All main verbs are S3 generics and provide methods
for \code{\link{tbl_df}}, \code{\link{tbl_dt}} and \code{\link{tbl_sql}}.}
\item{...}{Name-value pairs of summary functions like \code{\link{min}()},
\code{\link{mean}()}, \code{\link{max}()} etc.}
\item{.dots}{Used to work around non-standard evaluation. See
\code{vignette("nse")} for details.}
}
\value{
An object of the same class as \code{.data}. One grouping level will
be dropped.
Data frame row names are silently dropped. To preserve, convert to an
explicit variable.
}
\description{
Summarise multiple values to a single value.
}
\section{Backend variations}{
Data frames are the only backend that supports creating a variable and
using it in the same summary. See examples for more details.
}
\examples{
summarise(mtcars, mean(disp))
summarise(group_by(mtcars, cyl), mean(disp))
summarise(group_by(mtcars, cyl), m = mean(disp), sd = sd(disp))
# With data frames, you can create and immediately use summaries
by_cyl <- mtcars \%>\% group_by(cyl)
by_cyl \%>\% summarise(a = n(), b = a + 1)
\dontrun{
# You can't with data tables or databases
by_cyl_dt <- mtcars \%>\% tbl_dt() \%>\% group_by(cyl)
by_cyl_dt \%>\% summarise(a = n(), b = a + 1)
by_cyl_db <- src_sqlite(":memory:", create = TRUE) \%>\%
copy_to(mtcars) \%>\% group_by(cyl)
by_cyl_db \%>\% summarise(a = n(), b = a + 1)
}
}
\seealso{
Other single.table.verbs: \code{\link{arrange}},
\code{\link{filter}}, \code{\link{mutate}},
\code{\link{select}}, \code{\link{slice}}
}