Learn R Programming

regclass (version 1.5)

mode_factor: 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.

References

Introduction to Regression and Modeling

Examples

Run this code
	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)

  

Run the code above in your browser using DataLab