Learn R Programming

plyr (version 1.0.1)

count: Count the number of occurences.

Description

Count the number of occurences. Equivalent to as.data.frame(table(x)), but does not include combinations with zero counts.

Usage

count(df, vars)

Arguments

df
data frame to be processed
vars
variables to count unique values of

Value

  • a data frame with label and freq columns

Details

Count is speed competitive with table for single variables, but it really comes into its own when summarising multiple dimensions that are not crossed.

Examples

Run this code
count(baseball, "id")
count(baseball, "lg")
count(baseball, "stint")
count(count(baseball, c("id", "year")), "freq")

Run the code above in your browser using DataLab