Learn R Programming

cheapr (version 1.3.1)

cheapr_table: Fast frequency tables - Still experimental

Description

This is not a one-to-one copy of base::table() as some behaviours differ. It is more flexible as it accepts inputs such as data frames and vctrs_rcrd objects.

Usage

cheapr_table(
  ...,
  names = TRUE,
  order = FALSE,
  na_exclude = FALSE,
  classed = FALSE
)

counts(x, sort = is.factor(x))

Value

A named integer vector if one object is supplied, otherwise an array.

Arguments

...

>=1 objects that can be converted to a factor through cheapr::factor_().

names

Should level names be kept? Default is TRUE.

order

Should result be ordered by level names? Default is FALSE.

na_exclude

Should NA values be excluded? Default is FALSE.

classed

Should a table object be returned? Default is FALSE

x

A vector.

sort

Should groups be sorted? Default is FALSE.

Details

cheapr_table() tries to match the behaviour of table() where possible. counts() alternatively works only for atomic vectors and is faster, returning a data.frame of counts.