Learn R Programming

geostats (version 1.6)

Mode: get the mode of a dataset

Description

Computes the most frequently occuring value in a sampling distribution.

Usage

Mode(x, categorical = FALSE)

Value

a scalar

Arguments

x

a vector

categorical

logical. If TRUE, returns the most frequently occuring value for categorical variables. If FALSE, returns the value corresponding to the maximimum kernel density for continuous variables

Examples

Run this code
data(catchments,package='geostats')
m1 <- Mode(catchments$CaMg,categorical=TRUE)

m2 <- 1:50
for (i in m2){
   m2[i] <- Mode(rnorm(100),categorical=FALSE)
}
hist(m2)

Run the code above in your browser using DataLab