freq: Construct frequency table

View source: R/freq.R

freqR Documentation

Construct frequency table

Description

Prints a frequency table for the specified variable.

Usage

freq(
  df,
  var = NA,
  plot = interactive(),
  sort = TRUE,
  markdown = !interactive(),
  wt = NULL,
  na.rm = FALSE
)

Arguments

df

A data.frame (optionally, you can pass a variable as the first argument.)

var

a variable in the associated data.frame

plot

if TRUE prints bar chart of results. Default is TRUE if interactive(), otherwise FALSE

sort

If TRUE (default), sort output in descending order of n. If FALSE, sort output in ascending order of levels

markdown

if false, formats table for Rmarkdown/Quarto inclusion.

wt

a variable representing weights

na.rm

if FALSE (default) NAs are included in frequency list. If TRUE, NA are removed (but reported separately)

Details

This function constructs a frequency table for the specified variable. It expects a data.frame as the first argument and an (unquoted) variable as the second argument. It will thus fit into a tidyverse pipeline. Alternatively, for convenience, a vector can be passed as first argument and the var (second) argument left blank.

The console printed table is highly customizable using session, project, or global options. The following options are currently implemented and can be set by calling 'options()' either interactively or by including in your .Rprofile.

- simplefreqs.inner_table_padding

- simplefreqs.table_symbol

- simplefreqs.row_divider_symbol

- simplefreqs.print_table_symbol

- simplefreqs.print_table_total_row

- simplefreqs.print_table_metadata

- simplefreqs.print_header_divider

- simplefreqs.big_mark

- simplefreqs.decimal_digits

Value

data.frame containing frequencies.

Examples


freq(iris, Species, markdown = FALSE)


MartinLBarron/freqR documentation built on Aug. 28, 2023, 12:05 p.m.