Learn R Programming

MSMU (version 0.1.2)

estimate_mode: Estimate Mode using Density function to find Mode of continuous data

Description

Estimates the mode of a numeric vector by identifying the value corresponding to the peak of its estimated probability density function.

Usage

estimate_mode(x)

Value

A single numeric value representing the estimated mode.

Arguments

x

A numeric vector. Missing values (NA) are removed.

Examples

Run this code
# Estimate the mode of continuous random data
set.seed(123)
x <- rnorm(1000, mean=5, sd=2)
estimate_mode(x)

# Estimate the mode of miles-per-gallon (mpg) in the mtcars dataset
data("mtcars")
estimate_mode(mtcars$mpg)

Run the code above in your browser using DataLab