You are on page 1of 10

EXPERIMENT 6

#univariant plots
a = c(155,157,167,166,154,176,186,176,190)
plot(a)
OUTPUT:

#bivariant plot

a = c(4,5,6,8,7)

b = c(5,6,7,9,11)

plot(a,b,"l")

OUTPUT:

#TABLE

Rank = c(1,1,1,2,2,2,3,3,4,4,4)

table(Rank)

barplot(table(Rank))

table(Rank)/length(Rank)

barplot(table(Rank)/length(Rank))
OUTPUT:
Rank
1 2 3 4
3 3 2 3

Rank
1 2 3 4
0.2727273 0.2727273 0.1818182 0.2727273

#bar plot

A<-c(16,3,6,2,15,8)

b<-c("Jan","Feb","Mar","Apr","May","Jun")

#arranging title to graph,names,colour

barplot(A,names.arg=b,xlab="Month",ylab="No.of Holidays",col="pink",main="Holidays chart")

OUTPUT:

##

barplot(iris$Sepal.Length,col="pink")

OUTPUT:
##

barplot(iris$Sepal.Width,col=topo.colors(3))

OUTPUT:

##

barplot(iris$Sepal.Width,col=heat.colors(3))

OUTPUT:

#SUBDIVIDED BARS

cust=matrix(nrow=4,ncol=3,data=c(2,3,31,4,40,63,7,69,80,35,8,89),byrow=T)

barplot(cust)

#adding labels and colors

barplot(cust,names.arg=c('Row1','Row2','Row3'),xlab="Rows",ylab="Columns",
col=c('red','blue','green','yellow'))

OUTPUT:
#piechart

Rank = c(1,2,2,3,3,1,1,4,1,2)

Rank

table(Rank)

pie(table(Rank))

OUTPUT:

#adding labels

pie(table(Rank),labels=c("first","second","third","fourth"),main="person",col=c("red","skyblue","pale
green","purple"))

OUTPUT:

#3D pie diagram

library(plotrix)

A<-c(2,3,8,9,4,6)
pie3D(table(A), main = "sports", col = c("orange","yellow","green","violet","pink","blue"))

OUTPUT:

##

coust_details = c(2,4,5,3,6,9,2,3,4,5,6,3,4,5,6)

library(plotrix)

pie3D(coust_details)

OUTPUT:

pie3D(table(coust_details),labels=c("VJY","RJY","HYD","KDM","VZM","SKL"),main="customer
address",col=c("palegreen","blue","yellow","purple","pink","red"))

OUTPUT:

pie3D(table(coust_details),explode=0.2,labels=c("VJY","RJY","HYD","KDM","VZM","SKL"),main="cust
omer address",col=c("palegreen","blue","orange","purple","pink","red"))

OUTPUT:
##histogram

weight= c(57,52,49,51,45,53,55,42,50,59)

hist(weight)

hist(weight,main="Weights of students",col="powderblue",xlab="weight in kgs",ylab="no of


students")

OUTPUT:

library(RColorBrewer)

hist(VADeaths,col=brewer.pal(9,"Blues"),main="VADeaths")

OUTPUT:
hist(VADeaths,col=brewer.pal(10,"Reds"),main="VADeaths")

OUTPUT:

hist(VADeaths,breaks=10,col="lightyellow")

OUTPUT:

##coefficient of variance

marks = c(98,88,77,79,98,97,83,95)

summary(marks)

OUTPUT:
> summary(marks)
Min. 1st Qu. Median Mean 3rd Qu. Max.
77.00 82.00 91.50 89.38 97.25 98.00

#boxplot

boxplot(marks)

OUTPUT:
##two vectors

a = c(1,4,6,9,3,2,5,7)

b=c(5,3,6,9,3,8,4,9)

boxplot(data.frame(a,b))

boxplot(iris)

##heatmap

shop = matrix(nrow=4,ncol=3,data=c(3,6,7,8,4,2,5,9,4,2,7,6),byrow=T)

shop

heatmap(shop)

OUTPUT:

[,1] [,2] [,3]


[1,] 3 6 7

[2,] 8 4 2

[3,] 5 9 4

[4,] 2 7 6

##

prices = c(83,24,29,145,36,39,37,52,60)

mtx1 = matrix(prices,nrow=3,ncol=3,byrow=T)

mtx1

heatmap(as.matrix(mtx1))

OUTPUT:

[,1] [,2] [,3]

[1,] 83 24 29

[2,] 145 36 39

[3,] 37 52 60

#mosaicolot

##CATEGORILOGICAL DATA VER EFFICIENTLY


mosaicplot(as.matrix(shop),col= topo.colors(8))

OUTPUT:

mosaicplot(as.matrix(prices),col=heat.colors(10))

library(RColorBrewer)

mosaicplot(as.matrix(a),col=brewer.pal(9,"Blues"))

OUTPUT:

You might also like