Professional Documents
Culture Documents
Output:
> data=c(1,3,1,6,4,3,6,1,8,10,2,5,6,3,1)
> modus <- function(x) {
+ ux <- unique(x)
+ ux[which.max(tabulate(match(x, ux)))]
+ }
> distribusi <- function(x) {
+ hist(data, col = "peachpuff", border = "black", prob =
TRUE)
+ lines(density(data), lwd = 2, col = "chocolate3")
+ abline(v = mean(data), col = "royalblue", lwd = 2)
+ abline(v = median(data), col = "green", lwd = 2)
+ abline(v = modus(data), col = "red", lwd = 2)
+ }
> distribusi(data)