Learn R Programming

flashlight (version 0.9.0)

grouped_counts: Grouped count

Description

Calculates weighted counts grouped by optional columns.

Usage

grouped_counts(data, by = NULL, w = NULL, value_name = "n", ...)

Value

A data.frame with columns by and value_name.

Arguments

data

A data.frame.

by

An optional vector of column names in data used to group the results.

w

Optional name of the column in data with case weights.

value_name

Name of the resulting column with counts.

...

Arguments passed to sum() (only if weights are provided).

Examples

Run this code
grouped_counts(iris)
grouped_counts(iris, by = "Species")
grouped_counts(iris, w = "Petal.Length")
grouped_counts(iris, by = "Species", w = "Petal.Length")

Run the code above in your browser using DataLab