Learn R Programming

k5 (version 0.2.1)

count2: Count the way you want

Description

A wrapper around dplyr::count() with sort set to TRUE by default and the an additional column created by default containing the proportional fraction each observation makes of the whole.

Usage

count2(x, ..., wt = NULL, sort = TRUE, prop = TRUE, sum = NULL)

count_vec(x, sort = TRUE, prop = TRUE, sum = NULL)

Value

A tibble of element counts

Arguments

x

A data frame.

...

Variables to group by.

wt

Frequency weights.

sort

If TRUE, will show the largest groups at the top.

prop

If TRUE, compute the fraction of marginal table.

sum

Column to replace with a cumulative sum (n, p, or np).

Examples

Run this code
count2(iris, Species)

Run the code above in your browser using DataLab