Ba Assignment-2 Akshaya TV (011) Jidigam Snigdha (51) Karna Rohit Karteek Reddy Riya Mathew

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

BA ASSIGNMENT-2

AKSHAYA TV (011)
JIDIGAM SNIGDHA(51)
KARNA ROHIT()
KARTEEK REDDY()
RIYA MATHEW(088)
# Calling iris data
iris
names(iris)
library(dplyr)
irisspiecies=iris%>%count(Species)
irisspiecies

Sepal Length
# histogram for Sepal Length
hist(iris$Sepal.Length)
#colored histogram with number of different bins
hist(iris$Sepal.Length, breaks=5, col="red")

#normal curve
names(iris)
x=iris$Sepal.Length
h=hist(x,col="red", xlab="Sepal Length",
main="Histogram with Normal Curve")
xfit=seq(min(x),max(x))
yfit=dnorm(xfit,mean=mean(x),sd=sd(x))
yfit=yfit*diff(h$mids[1:2])*length(x)
lines(xfit, yfit, col="blue", lwd=2)

#kernel and density curves


d=density(iris$Sepal.Length)
plot(d, main="Kernel Density of sepal Length")
polygon(d, col="green", border="blue")

Sepal Width

# histogram for Sepal Width


hist(iris$Sepal.Width)
#colored histogram with number of different bins
hist(iris$Sepal.Width, breaks=5, col="red")
#normal curve
names(iris)
x=iris$Sepal.Width
h=hist(x,col="red", xlab="Sepal Width",
main="Histogram with Normal Curve")
xfit=seq(min(x),max(x))
yfit=dnorm(xfit,mean=mean(x),sd=sd(x))
yfit=yfit*diff(h$mids[1:2])*length(x)
lines(xfit, yfit, col="blue", lwd=2)

#kernel and density curves


d=density(iris$Sepal.Width)
plot(d, main="Kernel Density of sepal width")
polygon(d, col="green", border="blue")
Petal Length
# histogram for Petal Length
hist(iris$Petal.Length)
#colored histogram with number of different bins
hist(iris$Petal.Length, breaks=5, col="red")

#normal curve
names(iris)
x=iris$Petal.Length
h=hist(x,col="red", xlab="Petal length",
main="Histogram with Normal Curve")
xfit=seq(min(x),max(x))
yfit=dnorm(xfit,mean=mean(x),sd=sd(x))
yfit=yfit*diff(h$mids[1:2])*length(x)
lines(xfit, yfit, col="blue", lwd=2)
#kernel and density curves
d=density(iris$Petal.Length)
plot(d, main="Kernel Density of petal length")
polygon(d, col="green", border="blue")

Petal Width
#histogram for Petal width
hist(iris$Petal.Width)
#colored histogram with number of different bins
hist(iris$Petal.Width, breaks=5, col="red")
#normal curve
names(iris)
x=iris$Petal.Width
h=hist(x,col="red", xlab="Petal Width",
main="Histogram with Normal Curve")
xfit=seq(min(x),max(x))
yfit=dnorm(xfit,mean=mean(x),sd=sd(x))
yfit=yfit*diff(h$mids[1:2])*length(x)
lines(xfit, yfit, col="blue", lwd=2)

#kernel and density curves


d=density(iris$Petal.Width)
plot(d, main="Kernel Density of petal width")
polygon(d, col="green", border="blue")
mtcars
mtcars
names(mtcars)
# histogram for mpg
hist(mtcars$mpg)
#colored histogram with number of different bins
hist(mtcars$mpg, breaks=5, col="red")

#normal curve
names(mtcars)
x=mtcars$mpg
h=hist(x,col="red", xlab="mpg",
main="Histogram with Normal Curve")
xfit=seq(min(x),max(x))
yfit=dnorm(xfit,mean=mean(x),sd=sd(x))
yfit=yfit*diff(h$mids[1:2])*length(x)
lines(xfit, yfit, col="blue", lwd=2)
#kernel and density curves
d=density(mtcars$mpg)
plot(d, main="Kernel Density of mpg")
polygon(d, col="green", border="blue")

DISP

# histogram for disp


hist(mtcars$disp)
#colored histogram with number of different bins
hist(mtcars$disp, breaks=5, col="red")
#normal curve
names(mtcars)
x=mtcars$disp
h=hist(x,col="red", xlab="disp",
main="Histogram with Normal Curve")
xfit=seq(min(x),max(x))
yfit=dnorm(xfit,mean=mean(x),sd=sd(x))
yfit=yfit*diff(h$mids[1:2])*length(x)
lines(xfit, yfit, col="blue", lwd=2)

#kernel and density curves


d=density(mtcars$disp)
plot(d, main="Kernel Density of disp")
polygon(d, col="green", border="blue")
HP
# histogram for hp
hist(mtcars$hp)
#colored histogram with number of different bins
hist(mtcars$hp, breaks=5, col="red")

#normal curve
names(mtcars)
x=mtcars$hp
h=hist(x,col="red", xlab="hp",
main="Histogram with Normal Curve")
xfit=seq(min(x),max(x))
yfit=dnorm(xfit,mean=mean(x),sd=sd(x))
yfit=yfit*diff(h$mids[1:2])*length(x)
lines(xfit, yfit, col="blue", lwd=2)
#kernel and density curves
d=density(mtcars$hp)
plot(d, main="Kernel Density of hp")
polygon(d, col="green", border="blue")

Drat
# histogram for drat
hist(mtcars$drat)
#colored histogram with number of different bins
hist(mtcars$drat, breaks=5, col="red")
#normal curve
names(mtcars)
x=mtcars$drat
h=hist(x,col="red", xlab="drat",
main="Histogram with Normal Curve")
xfit=seq(min(x),max(x))
yfit=dnorm(xfit,mean=mean(x),sd=sd(x))
yfit=yfit*diff(h$mids[1:2])*length(x)
lines(xfit, yfit, col="blue", lwd=2)

#kernel and density curves


d=density(mtcars$drat)
plot(d, main="Kernel Density of drat")
polygon(d, col="green", border="blue")
WT
# histogram for wt
hist(mtcars$wt)
#colored histogram with number of different bins
hist(mtcars$wt, breaks=5, col="red")

#normal curve
names(mtcars)
x=mtcars$wt
h=hist(x,col="red", xlab="wt",
main="Histogram with Normal Curve")
xfit=seq(min(x),max(x))
yfit=dnorm(xfit,mean=mean(x),sd=sd(x))
yfit=yfit*diff(h$mids[1:2])*length(x)
lines(xfit, yfit, col="blue", lwd=2)
#kernel and density curves
d=density(mtcars$wt)
plot(d, main="Kernel Density of wt")
polygon(d, col="green", border="blue")

qsec
# histogram for qsec
hist(mtcars$qsec)
#colored histogram with number of different bins
hist(mtcars$qsec, breaks=5, col="red")
#normal curve
names(mtcars)
x=mtcars$qsec
h=hist(x,col="red", xlab="qsec",
main="Histogram with Normal Curve")
xfit=seq(min(x),max(x))
yfit=dnorm(xfit,mean=mean(x),sd=sd(x))
yfit=yfit*diff(h$mids[1:2])*length(x)
lines(xfit, yfit, col="blue", lwd=2)

#kernel and density curves


d=density(mtcars$qsec)
plot(d, main="Kernel Density of qsec")
polygon(d, col="green", border="blue")

You might also like