Ba Assignment-2 Akshaya TV (011) Jidigam Snigdha (51) Karna Rohit Karteek Reddy Riya Mathew
Ba Assignment-2 Akshaya TV (011) Jidigam Snigdha (51) Karna Rohit Karteek Reddy Riya Mathew
Ba Assignment-2 Akshaya TV (011) Jidigam Snigdha (51) Karna Rohit Karteek Reddy Riya Mathew
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)
Sepal Width
#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)
#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
#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)
#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)