Learn R Programming

eeptools (version 0.1)

statamode: to mimic the mode function in Stata.

Description

This function mimics the functionality of the mode function in Stata. It does this by calculating the modal category of a vector and replacing tied categories with a "." to represent a single mode does not exist.

Usage

statamode(x)

Arguments

x
a numeric vector, missing values are allowed

Value

  • The modal value of a vector if a unique mode exists, else "."

See Also

table which this function uses

Examples

Run this code
# for vectors
a<-c(month.name,month.name)
statamode(a) # returns "." to show no unique mode; useful for ddply
a<-c(LETTERS,"A","A")
statamode(a)

Run the code above in your browser using DataLab