counts: Generate Counts of Values in a Vector

View source: R/misc_functions.R View source: R/RcppExports.R

countsR Documentation

Generate Counts of Values in a Vector

Description

This function uses Rcpp sugar to implement a fast table, for unique counts of a single vector. This implementation seeks to produce identical output to table(x, useNA="ifany"). It is borrowed from Kmisc package for convenience, since Kmisc is not in CRAN anymore. Kmisc is available at https://github.com/kevinushey/Kmisc

Usage

counts(x)

Arguments

x

A numeric, integer, character or logical vector, or a (potentially nested) list of such vectors. If x is a list, we recursively apply counts throughout elements in the list.

Details

The order of NA, NaN in the output may differ – even R is inconsistent with the order that NA and NaN elements are inserted.

Examples

x <- round( rnorm(1E2), 1 )
counts(x)

ChristK/CKutils documentation built on April 11, 2025, 10:11 p.m.