This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mode<-function(v){ | |
occur<-table(v) #Creates a table with unique numbers as labels (ascending order) and occurrences in the first row. | |
boolean<-max(occur) == occur #max(v) extracts the maximum number from 'occur' and matches with the original set to give boolean values | |
value<-names(occur)[boolean] #Searches for label having 'TRUE' | |
return as.numeric(value) | |
} |