count: Count Occurrences of Unique Vector Elements

View source: R/count.R

countR Documentation

Count Occurrences of Unique Vector Elements

Description

Counts the number of occurrences of each element in the provided vector. Counting of NAs in addition to non-NA values is supported.

Usage

count(vec = NULL)

Arguments

vec

(vector) vector containing elements to count

Value

(dataframe) two-column dataframe with as many rows as there are unique elements in the provided vector. First column is named "value" and includes the unique elements of the vector, second column is named "count" and includes the number of occurrences of each vector element.

Examples

# Count instances of vector elements
count(vec = c(1, 1, NA, "a", 1, "a", NA, "x"))


supportR documentation built on June 22, 2024, 10:17 a.m.