cat_freqs: Create column for frequency distribution of data

View source: R/cat_freqs.R

cat_freqsR Documentation

Create column for frequency distribution of data

Description

Create column for frequency distribution of data

Usage

cat_freqs(
  x,
  omit_na = T,
  NAname = NA,
  digits = 1,
  incl_denom = F,
  remove_na = F,
  out = c("percentage", "percent"),
  perc_disp = F,
  escape = F,
  zero2dash = T
)

Arguments

x

vector of characters or factors

omit_na

logical for ommision of NAs in computation of counts and proportions of non missing data

digits

number of digits to round

incl_denom

logical for inclusion of denominator when displaying frequencies

remove_na

logical for removal of frequency of missing data

out

single character representing output for proportion

perc_disp

logical for inclustion of % sign

escape

logical for inclusion of escape character for LaTeX tables

zero2dash

logical for returning "-" instead of "0 (0)" for tables

Value

dataframe/tibble with two columns, one for category name, and one with N (\

Examples

dat = iris
specs = dat$Species
cat_freqs(specs)
cat_freqs(iris$Species)

#Playing around with Missing data

set.seed(314159)
index_na = sample(1:nrow(dat), size = 25, replace = F)
dat[index_na,]$Species = NA

# Different output based on arguments to `omit_na`
cat_freqs(dat$Species) #omit_na = F default
cat_freqs(dat$Species, omit_na = T)
cat_freqs(dat$Species, incl_denom = T)

Ajfrick/ajfhelpR documentation built on June 30, 2023, 12:56 a.m.