find mean median mode using R
Applied statistics using R problems R Studio Sample Codes

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?

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

Applied statistics using R problem 1
Problem 1

One Reply to “Find Mean Median and Mode of Data Set Using R

Leave a Reply

Your email address will not be published.