Measure of Central Tendency Practical
Measure of Central Tendency Practical
# Defining vector
x <- c(3, 7, 5, 13, 20, 23, 39, 23, 40, 23, 14, 12, 56, 23)
# Print mean
print(mean(x))
Output:
[1] 21.5
# Defining vector
x <- c(3, 7, 5, 13, 20, 23, 39,
23, 40, 23, 14, 12, 56, 23)
# Print Median
median(x)
Output:
[1] 21.5
# Defining vector
x <- c(3, 7, 5, 13, 20, 23, 39,
23, 40, 23, 14, 12, 56,
23, 29, 56, 37, 45, 1, 25, 8)
# Mode of x
m <- names(y)[which(y == max(y))]
# Print mode
print(m)
Output:
x
1 3 5 7 8 12 13 14 20 23 25 29 37 39 40 45 56
1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 2
[1] "23"
# Defining vector
x <- c(3, 7, 5, 13, 20, 23, 39, 23, 40,
23, 14, 12, 56, 23, 29, 56, 37,
45, 1, 25, 8, 56, 56)
# Mode of x
m <- names(y)[which(y == max(y))]
# Print mode
print(m)
Output:
x
1 3 5 7 8 12 13 14 20 23 25 29 37 39 40 45 56
1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 4
[1] "23" "56"
Output:
[1] 28.78889
# R program to illustrate
# Descriptive Analysis
Output:
[1] 26
Output:
[1] 25
Output:
OUTPUT: MEAN
[1] 33.24089
OUTPUT: MEDIAN
[1] 29