- 20 Students Graduates and under graduates were enrolled in a maths course. Their ages were 18, 19, 19, 19, 19,20,20,20,20,20,21,21,21,21,22,23,24,27,30,36
-
Find the median age of all students.
-
Find the median age of all students under 25 years
-
Find the mode age of all students
-
Find the mean age of all students
-
Two more students enter the class. Age of both students is 19. What is the mean, median and mode now?
Answers:-
age<-c(18,19,19,19,19,20,20,20,20,20,21,21,21,21,22,23,24,27,30,36)
median(age)
[1] 20.5
age[age<25]
[1] 18 19 19 19 19 20 20 20 20 20 21 21 21 21 22 23 24
median(age[age<25])
[1] 20
n=table(age)
n
age
18 19 20 21 22 23 24 27 30 36
1 4 5 4 1 1 1 1 1 1
mod<-which(n==max(n));
> mod 20 3
mean(age)
[1] 22
age<-c(age,19,19)
median(age)
[1] 20
mean(age)
[1] 21.72727
n=table(age)
> n age 18 19 20 21 22 23 24 27 30 36 1 6 5 4 1 1 1 1 1 1
mod<-which(n==max(n))
> mod 19 2
The screen shot of the following program is given below
One Reply to “Find Mean Median and Mode of Data Set Using R”