HARSHA TL
2513711034020
SIMPLE BAR DIAGRAM
1. Create a bar diagram to display the number of students enrolled in different courses at a
college. The data is as follows:
Course commerce journalism psychology viscom sociology
students 60 50 30 40 35
CODING:
a=c(60,50,30,40,35)
barplot(a,main="MYBARCHAT",xlab="course",ylab="students",names.arg=c("commerce","journalis
m","psycology","viscom","sociology"),col="red")
OUTPUT:
THE SIMPLE BAR DIAGRAM IS DISPLAYED
HARSHA TL
2513711034020
HORIZONTAL BAR DIAGRAM
1. Create a horizontal bar diagram to visualize the sales of different products in a store. The
sales data (in units) for each product is given below:
Product laptops tablets Smartphones monitors keyboards
sales 120 90 150 60 80
CODING:
a=c(120,90,150,60,80)
barplot(a,main="MYBARCHAT",xlab="product",ylab="sales",names.arg=c("laptops","tablets","smart
phones","monitors","keyboards"),col="pink",horiz=TRUE)
OUTPUT:
THE HORIZONTAL BAR DIAGRAM IS DISPLAYED
HARSHA TL
2513711034020
MULTIPLE BAR DIAGRAM
1. A school conducted exams for three classes (class A, B, and C) in five subjects :
Maths, Science, Social, Language, English. The AVERAGE SCORE of students in each class
are shown below:
Subjects Class A Class B Class C
Maths 78 86 66
Science 83 79 86
Social 77 65 98
English 98 84 52
Language 90 87 79
CODING:
d=matrix(c(78,83,77,98,90,86,79,65,84,87,66,86,98,52,79),nrow=3,ncol=5,byrow=TRUE)
barplot(d,main="AVERAGESCORE",xlab="SUBJECTS",ylab="CLASS",names.arg=c("maths","science",
"social","english","language"),col=c("white","black","grey"),beside=TRUE)
legend(x=1,y=11,c("classA","classB","ClassC"),cex=0.7,col=c("white","black","grey"),pch=20)
OUTPUT:
THE MULTIPLE BAR DIAGRAM IS DISPLAYED
HARSHA TL
2513711034020
SUBDIVIDED BAR DIAGRAM
1. A Company tracks the quarterly sales performance of three products (Product X, Product Y and Product Z)
Over three quarters. The data (in thousands of dollars) is as follows:
Quarter Product X Product Y Product Z
Q1 30 20 10
Q2 45 25 35
Q3 40 30 15
CODING:
d=matrix(c(30,45,40,20,25,30,10,35,15),nrow=4,ncol=3,byrow=TRUE)
barplot(d,main="SALES PERFORMANCE",xlab="QUARTER",ylab="PRODUCT",names.arg=c("Q1",
"Q2", "Q3"),col=c("violet","blue","orange"))
legend(x=1,y=11,c("ProductX","ProductY","ProductZ"),cex=0.7,col=c("violet","blue","orange"),pch=20
OUTPUT:
THE SUBDIVIDED BAR DIAGRAM IS DISPLAYED
HARSHA TL
2513711034020
SIMPLE HISTOGRAM
1. A researcher recorded the ages of 20 participants in a study as follows:
Ages 30 22 25 29 31 24 28 33 27 26
Ages 24 30 34 21 23 32 29 26 28 25
CODING:
ages=c(30,22,25,29,31,24,28,33,27,26,24,30,34,21,23,32,29,26,28,25)
hist(ages,main="AGES",xlab="ages",ylab="participants",xlim=c(21,34),col="green",freq=
TRUE)
OUTPUT:
THE SIMPLE HISTOGRAM IS DISPLAYED
HARSHA TL
2513711034020
PIE DIAGRAM
1. A survey was conducted to find the favourite types of fruit among a group of people.
Fruit Apples Bananas Oranges Grapes Mangoes
No.of 30 20 25 15 10
People
CODING:
e=c(30,20,25,15,10)
pie(e,labels=c("Apples","Bananas","Oranges","Grapes","Mangoes"),main="FAVOURITE
TYPES OF FRUIT",col=c("yellow","pink","red","violet","blue"),clockwise=TRUE)
OUTPUT:
THE PIE DIAGRAM IS DISPLAYED
HARSHA TL
2513711034020
LINE DIAGRAM
1. The monthly average temperature (in ºc) of a city over the first six months of the year is
recorded as follows:
Month City A City B
Jan 5 10
Feb 7 12
Mar 12 15
Apr 18 20
May 22 25
June 26 30
CODING:
z=c(1:6)
CityA=c(5,7,12,18,22,26)
CityB=c(10,12,15,20,25,30)
plot(z,CityA,type="o",col="grey",main="temperature",xlab="months",ylab="city")
lines(z,CityB,type="o",col="black")
OUTPUT:
THE LINE DIAGRAM IS DISPLAYED
HARSHA TL
2513711034020
MEASURES OF CENTRAL TENDENCY
1. The annual profits (in ₹) made by 10 different retail stores are:
₹12300, ₹14500, ₹13200, ₹12800, ₹15600, ₹13900, ₹12700, ₹14100, ₹15200.
calculate the mean profit of the stores.
CODING:
f=c(12300,14500,13200,12800,15600,13900,12700,14100,13400,15200)
mean(f)
OUTPUT:
>mean(f)
[1] 13770
HARSHA TL
2513711034020
2. The number of visitors to a historical monument over 11 consecutive days is as follows:
9450, 9600, 9300, 9750, 9500, 9400, 9800, 9550, 9700, 9350, 9650. Find the median number
of visitors.
CODING:
g=c(9450,9600,9300,9750,9500,9400,9800,9550,9700,9350,9650)
median(g)
OUTPUT:
>median(g)
[1]9550
HARSHA TL
2513711034020
3. The following are the test scores (out of 1000) of 15 students in a national-level exam :520,
635, 710, 635, 690, 750, 635, 580, 645, 710, 690, 520, 600, 635, 660 calculate the mode of
the scores
CODING:
h=c(520,635,710,635,690,750,635,580,645,710,690,520,600,635,660) t=table(as.vector(h))
t
names(t)[t=max(t)]
OUTPUT:
>names(t)[t=max(t)]
[1] "635"
HARSHA TL
251371034020
MEASURES OF DISPERSION
1. The following are the final exam scores (out of 1000) of 12 students:
865, 890, 910, 875, 880, 895, 900, 920, 870, 885, 895, 905 what is the range and coefficient
of range?
CODING:
e=c(865,890,910,875,880,895,900,920,870,885,895,905)
range(e)
(#Run after this to get the two values displayed in console)
r=(920-865)
r
cr=(920-865)/(920+865)
cr
OUTPUT:
Range =55
Coefficient of range = 0.03081232
HARSHA TL
2513711034020
2. The following are the monthly electricity bills (in ) of 15 households in a society :845, 890,
860, 875, 930, 920, 870, 880, 865, 855, 910, 895, 875, 885, 905. calculate the quartile
deviation and coefficient of quartile deviation.
CODING:
f=c(845,890,860,875,930,920,870,880,865,855,910,895,875,885,905)
quantile(f,0.25) (#Run after this to get Q1)
quantile(f,0.75) (#Run after this to get Q3)
QD=((900-867.5)/2)
QD
CQD=((900-867.5)/(900+867.5) )
CQD
OUTPUT:
The quartile deviation for the given data is 16.25
The coefficient of quartile deviation is 0.01838755
HARSHA TL
2513711034020
3. The number of units produced per day by a machine over 10 consecutive days : 1120,
1135, 1100, 1115, 1140, 1125, 1110, 1130, 1150, 1120. Calculate standard deviation and
coefficient of variation.
CODING:
g=c(1120,1135,1100,1115,1140,1125,1110,1130,1150,1120)
sd(g)
cv=((sd(g)/mean(g))*100)
cv
OUTPUT:
Standard deviation = 14.80428
Coefficient of variation= 1.316521
HARSHA TL
2513711034020
CORRELATION AND REGRESSION
1. Find the coefficient of correlation for the following data
X 92 89 87 86 83 77 71 63 53 50
Y 86 83 91 77 68 85 52 82 37 57
CODING:
x=c(92,89,87,86,83,77,71,63,53,50)
y=c(86,83,91,77,68,85,52,82,37,57)
cor(x,y,method="pearson")
OUTPUT:
[1]0.7290816
HARSHA
2513711034020
2. The following are the ranks by 10 students in Tamil and English. Calculate the rank
correlation coefficient.
Tamil 1 2 3 4 5 6 7 8 9 10
English 1 4 2 5 3 9 7 10 6 8
CODING:
x=c(1,2,3,4,5,6,7,8,9,10)
y=c(1,4,2,5,3,9,7,10,6,8)
cor(x,y,method="spearman")
OUTPUT:
[1]0.7818182
HARSHA TL
2513711034020
3. Obtain the equation of the line of regression of yields rice on water from the data given in
the following table which shows the amount of applied in inches and the yields of rice in tons
per acre in an experimental farm. Estimate the most probable yield of rice of 40 inches of
water.
Water x 12 18 24 30 36 42 48
Yield y 5.27 5.68 6.25 7.21 8.02 8.71 8.42
CODING:
x=c(12,18,24,30,36,42,48)
y=c(5.27,5.68,6.25,7.21,8.02,8.71,8.42)
R1=lm(x~y)
R1
R2=lm(y~x)
R2
Reg=(0.1029*40)+3.9943
Reg
X=9.193*y-35.087
Y=0.1029*x+3.9943
OUTPUT:
>Reg
[1] 8.1103