mode_factor: Find the mode of a categorical variable

View source: R/mode_factor.R

mode_factorR Documentation

Find the mode of a categorical variable

Description

This function finds the mode of a categorical variable

Usage

mode_factor(x)

Arguments

x

a factor

Details

The mode is the most frequently occuring level of a categorical variable. This function returns the mode of a categorical variable. If there is a tie for the most frequent level, it returns all modes.

Author(s)

Adam Petrie

References

Introduction to Regression and Modeling

Examples

	data(EX6.CLICK)
  mode_factor(EX6.CLICK$DeviceModel)
  
  #To see how often it appears try sorting a table
  sort( table(EX6.CLICK$DeviceModel),decreasing=TRUE )
  
  x <- c( rep(letters[1:4],5), "e", "f" )  #multimodel
  mode_factor(x)

  

regclass documentation built on June 8, 2025, 12:40 p.m.