MINI MINI MANI MO

Path : /opt/oracle/product/18c/dbhomeXE/R/library/OREdplyr/doc/man/en/
File Upload :
Current File : //opt/oracle/product/18c/dbhomeXE/R/library/OREdplyr/doc/man/en/tally.Rd

%
% Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
%
\name{tally}
\alias{count}
\alias{count_}
\alias{tally}
\title{Counts or Tallies Rows by Group}
\usage{
tally(x, wt, sort = FALSE)

count(x, ..., wt = NULL, sort = FALSE)

count_(x, vars, wt = NULL, sort = FALSE)
}
\arguments{
\item{x}{A grouped \code{\link[OREbase:ore.frame-class]{ore.frame}} object to tally or count.}

\item{wt}{If not specified, tally the number of rows.
If specified, perform a weighted tally by summing over the weight values.}

\item{sort}{Whether to sort output in descending order of \code{n}.}

\item{..., vars}{Columns to group by.}
}
\description{
\code{tally} is a convenient wrapper for \code{\link{summarise}} that will either call
\code{n} or \code{\link{sum}(n)} depending on whether you're tallying
for the first time, or re-tallying.
\code{count} is similar, but it does the \code{\link{group_by}} for you.
\code{count_} uses \code{vars} to specify the groupng column names.
}
\examples{
MTCARS <- ore.push(mtcars)
arrange(tally(group_by(MTCARS, cyl)), cyl)
tally(group_by(MTCARS, cyl), sort = TRUE)

# Multiple tallys progressively roll up the groups
cyl_by_gear <- tally(group_by(MTCARS, cyl, gear), sort = TRUE)
tally(cyl_by_gear, sort = TRUE)
tally(tally(cyl_by_gear))

cyl_by_gear <- tally(group_by(MTCARS, cyl, gear), wt = hp,  sort = TRUE)
tally(cyl_by_gear, sort = TRUE)
tally(tally(cyl_by_gear))

cyl_by_gear <- count(MTCARS, cyl, gear, wt = MTCARS[["hp"]] + mpg, sort = TRUE)
tally(cyl_by_gear, sort = TRUE)
tally(tally(cyl_by_gear))

library(magrittr)
MTCARS \%>\% group_by(cyl) \%>\% tally(sort = TRUE)

# count is more succinct and also does the grouping
MTCARS \%>\% count(cyl) \%>\% arrange(cyl)
MTCARS \%>\% count(cyl, wt = hp) \%>\% arrange(cyl)
MTCARS \%>\% count_("cyl", wt = hp, sort = TRUE)

}


OHA YOOOO