Learn R Programming

supportR (version 1.5.0)

count: 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)

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.

Arguments

vec

(vector) vector containing elements to count

Examples

Run this code
# Count instances of vector elements
supportR::count(vec = c(1, 1, NA, "a", 1, "a", NA, "x"))

Run the code above in your browser using DataLab