# Create the dataset
data <- c(3, 3, 3, 4, 4, 4, 5, 5, 5)
# Calculate the mean
mean_value <- mean(data)
# Calculate the median
median_value <- median(data)
# Calculate the mode
find_mode <- function(x) {
uniq_x <- unique(x)
freq_x <- table(x)
max_freq <- max(freq_x)
mode <- as.numeric(names(freq_x[freq_x == max_freq]))
return(mode)
}
mode_value <- find_mode(data)
# Print the results
cat("Mean:", mean_value, "\n")
cat("Median:", median_value, "\n")
cat("Mode:", mode_value, "\n")
0 Comments