# tally

From dplyr v0.1.1
by Hadley Wickham

##### Tally observations by group.

`tally`

is a convenient wrapper for summarise that
will either call `n`

or `sum(n)`

depending on whether you're tallying for the first time, or
re-tallying.

##### Usage

`tally(x, wt, sort = FALSE)`

##### Arguments

- x
- a
`tbl`

to tally - wt
- if not specified, will tally the number of rows. If specified, will perform a "weighted" tally but summing over the specified variable.
- sort
- if
`TRUE`

will sort output in descending order of`n`

##### Examples

```
if (require("Lahman")) {
batting_tbl <- tbl_df(Batting)
tally(group_by(batting_tbl, yearID))
tally(group_by(batting_tbl, yearID), sort = TRUE)
# Multiple tallys progressively role up the groups
plays_by_year <- tally(group_by(batting_tbl, playerID, stint), sort = TRUE)
tally(plays_by_year, sort = TRUE)
tally(tally(plays_by_year))
# This looks a little nicer if you use the infix %.% operator
batting_tbl %.% group_by(playerID) %.% tally(sort = TRUE)
}
```

*Documentation reproduced from package dplyr, version 0.1.1, License: MIT + file LICENSE*

### Community examples

Looks like there are no examples yet.