mean, median, sd
In this page:
mean, median, sd
mean() computes the arithmetic average, median() finds the middle value, and sd() computes the standard deviation of a numeric vector. All three are fundamental descriptive statistics used to summarize a dataset's central tendency and spread. Each has an na.rm = TRUE argument to ignore missing values when computing the result.
Note: If a vector contains NA, mean() returns NA by default -- pass na.rm = TRUE to ignore missing values.
Example: mean, median, sd
scores <- c(85, 90, 78, 92, 88)
cat("Mean:", mean(scores), "\n")
cat("Median:", median(scores), "\n")
cat("Std Dev:", sd(scores), "\n")
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: