# Find Mean Median and Mode of Data Set Using R

• 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
1. Find the median age of all students.

2. Find the median age of all students under 25 years

3. Find the mode age of all students

4. Find the mean age of all students

5. Two more students enter the class. Age of both students is 19. What is the mean, median and mode now?

age<-c(18,19,19,19,19,20,20,20,20,20,21,21,21,21,22,23,24,27,30,36)

median(age)

` 20.5`

age[age<25]

` 18 19 19 19 19 20 20 20 20 20 21 21 21 21 22 23 24`

median(age[age<25])

` 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)

` 22`

age<-c(age,19,19)

median(age)

` 20`

mean(age)

` 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 