Professional Documents
Culture Documents
YASH RUGHWANI
ASSIGNMENT-6
Q.1 Plot Miles/(US) gallon versus Rear axle ratio by plot(mpg,drat). On which
axis does mpg appear?
a. mpg appears on the x axis
b. mpg appears on the y axis
Q.2Produce a histogram with hist(gear). What do you see?
a. frequencies
b. probability density
x <- c(1, 2, 3, 4, 5)
y <- c(10, 20, 15)
plot(x, y, main = "Scatter Plot of Two Vectors", xlab = "Vector X", ylab = "Vector
Y")
legend("topright", legend = "Data Points", pch = 1)
Q8 1.Draw a pie chart for 5 vector value.
2. set start angle for pie chart
3.label 4.main 5.legend
>x<-c(10,20,30,40,50)
> pie(x)
2.
> pie(x,init.angle=90)
3+4.
> x<-c(10,20,30,40,50)
> mylabel<-c("APPLES","BANANAS","MANGO","ORANGE","GRAPES")
> pie(x,label=mylabel,main="FRUITS")
5.
>mylabel<-c("APPLES","GRAPES","MANGOES","WATERMELON","CHERRY
")
> colors<-c("RED","PURPLE","YELLOW","GREEN","PINK")
> pie(x,label=mylabel,main="Pie Chart",col=colors)
> legend("bottomleft",mylabel,fill=colors)
Ques9)Draw a bar chart for student name
and marks. 1 Set bar color green and red.
2.set density and width(1
or 2 or 3) Program:
> marks<-c(17,32,66,40,23,34,64,61,47,54)
>studentname<-c("AAYUSH","NITESH","YASHR","YASHV","UMANG","PRA
NAY","KAUSH AL","KISHAN","MANYA","DIVYA")
>barplot(marks,names.arg=studentname,xlab="MARKS",ylab="STUDENTNAM
ES",col="green", main="CLASS ANALYSIS")
>barplot(marks,names.arg=studentname,xlab="MARKS",ylab="STUDENTNAM
ES",col="RED",
main="CLASS ANALYSIS")
>barplot(marks,names.arg=studentname,xlab="MARKS",ylab="STUDENTNAM
ES",col="RED", main="CLASS ANALYSIS",width=c(1,3,2,2,1,2,3,1,3,2))
Ques10)Draw horizontal bar student name and marks
(10 students). Program:
> x<-c(17,32,89,40,23)
> marks<-c(17,32,66,40,23,34,64,61,47,54)
>studentname<-c("AAYUSH","NITESH","YASHR","YASHV","UMANG","PRA
NAY","KAUS HAL","KISHAN","MANYA","DIVYA")
>barplot(marks,name.arg=studentname,horiz=TRUE,xlab="marks",ylab="studentn
ame",main=" Horizontal Bar-Chart”)