Assignment-1
R-Programming
Name :- Devesh Tiwari
Roll no:- 72010980
Submitted to:- Ms. Kamal Malik
Q1. Download any 5 datasets and do the data
analytics of it by performing each and every
computation on it including summary, inspection
and visualization of insights of data sets and
many more.(ASSIGNMENT No 1).
Code:-
data()
#in this practice i will used inbuilt datsets in r programming i used for the
referececes
#mtcars data set which over the more specific and more generic with good
valuation.
#loading the datssets
cat("1:-dataset 1 ...mtcars datasets")
data("mtcars")
head(mtcars,6)
?mtcars
data("mtcars")
head(mtcars)
nrow(mtcars)
ncol(mtcars)
#basic summary of the dataset.
data(mtcars)
head(mtcars)
summary(mtcars)
#visualization of the dataset
plot(mtcars$wt, mtcars$mdg, xlab="Weight (1000 lbs)", ylab="Miles per
gallon")
corr<-cor(mtcars[,1:11])
corrplot::corrplot(corr,method="color",type="upper")
Output:
#===============================================================
================
#loading the datssets
cat("2:- dataset 2 ...iris datasets")
data("iris")
head(iris,6)
?iris
data("iris")
head(iris)
nrow(iris)
ncol(iris)
#basic summary of the dataset.
data(iris)
head(iris)
summary(iris)
#visualization of the dataset
plot(iris$Sepal.Length, iris$Sepal.Width, col=iris$Species,xlab="Sepal legth",
ylab="Sepal Width")
corr<-cor(iris[,1:4])
corrplot::corrplot(corr,method="color",type="upper")
output:-
#===============================================================
========================
#loading the datasets.
cat("3:- dataset 3 ...ToothGrowth datasets")
data("ToothGrowth")
head(ToothGrowth,6)
?ToothGrowth
data("ToothGrowth")
head(ToothGrowth)
nrow(ToothGrowth)
ncol(ToothGrowth)
#basic summary of the datasets.
data(ToothGrowth)
head(ToothGrowth)
summary(ToothGrowth)
#visualization of the datasets.
pairs(ToothGrowth)
#By using boxplot.
boxplot(len~dose,data=ToothGrowth,xlab="Dose (mg/day)",ylab="Tooth
length (mm)", main="R Boxplot in Example",method="color")
#by using plot method to deply the renge of the data.
plot(ToothGrowth$len ~ ToothGrowth$dose,
xlab = "Dose (mg/day)",
ylab ="Tooth length (mm)",
main = "Tooth Growth by vitamin c Dose",
col = "blue",
pch = 19 )
#in this datasets we saw the at our data set gone upto the range of the 5-35.
#and its recurances is the upto the mark of the prediction.
Output:-
#===============================================================
================
#for the longley dataset where we predict the best longest's economic
regression
# to finding their represent in the r programming language.
cat("4:- dataset 4 ...longley datasets")
data("longley")
data(longley)
?longley
#basic summary of the datasets.
data(longley)
head(longley)
summary(longley)
#visualisation of the datasets.
pairs(longley)
# Visualization of the dataset using plot()
plot(longley$GNP, longley$Employed, xlab = "Gross National Product", ylab =
"Employment", main = "GNP vs Employment")
# Visualization of the dataset using boxplot()
boxplot(longley$GNP, longley$GNP.deflator, longley$Unemployed,
longley$Armed.Forces,
longley$Population, longley$Year,
main = "Boxplot of Longley dataset")
#linear regression analysis.
model<-lm(Employed~.,data=longley)
summary(model)
output:-
#conclusion:- here the ranges implies is in the 250-450.
#===============================================================
================
#in this collection of the dataset we saw that islands data is the sepcific area of
the
#seas.
cat("5:- dataset 5 ...longley datasets")
data("longley")
data(longley)
?longley
#basic summary of the given the dataset.
#loading the datasets.
data(AirPassengers)
?AirPassengers
summary(AirPassengers)
Output:-