Description Usage Arguments Examples
This function calculates the mode for an integer valued data vector by default. It also calculates "nmore" more modes than the most frequently occurring value and can take in data that should be treated as integers, real numbers (which can optionally be rounded to the "digits" number of significant digits), or factors. This modes function finds the value(s) that occur most frequently so, crucially, if there is a tie in the frequency count for the mode it will yield two modes instead of the lower valued mode. Yielding all modes instead of just the lowest mode is particularly important when more advanced statistics and machine learning techniques are employed.
1 |
data |
Data vector. |
type |
The type of data the vector contains. Defaults to 1.
|
digits |
How many significant digits should be retained? Defaults to NULL. |
nmore |
Specifices how many modes should be attempted. That is, it finds the "nmore" modes with decreasing frequency. For example, if the data is bimodal, specify nmore=2 and the two most frequent values with their frequency will be returned. |
... |
Pass through arguments. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #Example 1
data<-c(rep(6,9),rep(3,3))
modes(data,type=1,"NULL","NULL")
#Example 2
data<-c(rep(6,9),rep(3,9))
modes(data,type=1,"NULL","NULL")
#Example 3
data<-c(rep(6,9),rep(3,8),rep(7,7),rep(2,6))
modes(data,type=1,"NULL",2)
#Example 4
data<-c(rnorm(15,0,1),rnorm(21,5,1),rep(3,3))
modes(data)
#Example 5
data<-c(rep(6,3),rep(3,3),rnorm(15,0,1))
modes(data,3,NULL,4)
modes(data,type=2,digits=1,3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.