0% found this document useful (0 votes)
6 views

Presentation 3

The document presents an analysis of energy imports from various countries between 1960 and 2005, focusing on comparisons among Australia, Spain, and Germany, as well as a broader analysis of energy consumption in Luxembourg, Denmark, and Greece. It includes visual representations such as bar plots, box plots, and pie charts to illustrate trends and discrepancies in energy imports over the years. The analysis aims to provide insights into energy import patterns and consumption across different nations.

Uploaded by

timjain9
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Presentation 3

The document presents an analysis of energy imports from various countries between 1960 and 2005, focusing on comparisons among Australia, Spain, and Germany, as well as a broader analysis of energy consumption in Luxembourg, Denmark, and Greece. It includes visual representations such as bar plots, box plots, and pie charts to illustrate trends and discrepancies in energy imports over the years. The analysis aims to provide insights into energy import patterns and consumption across different nations.

Uploaded by

timjain9
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Presentation

AJ
2024-12-08
1 Following is the data which we have chosen i.e Energy Imports of every country from 1960 to 2005
2 We will now see energy imports of 3 Countries and compare them over the 45 years
3 Now we will compare maximum energy imported from 1960 to 2000 (10 years gap)
4 Comparing Boxplot for all countries from the year 1960 to 1970
5 Comparing energy consumption of Luxumbourg , Denmark and Greece every 15 years
6 Mean of all countries for the years 1970 - 1980 displayed in a pie chart
7 Comparison Between Energy Imports of India and Pakistan during 1980 - 1990

1 Following is the data which we have chosen i.e Energy


Imports of every country from 1960 to 2005
getwd()

## [1] "/Users/shreyans/Desktop/Stats With R"

energy3<-read.csv(file="energy3.csv",header=T)
head(energy3)
## Country.Name Country.Code
## 1 Aruba ABW
## 2 Africa Eastern and Southern AFE
## 3 Afghanistan AFG
## 4 Africa Western and Central AFW
## 5 Angola AGO
## 6 Albania ALB
## Indicator.Name Indicator.Code X1960 X1961 X1962 X1963
## 1 Energy imports, net (% of energy use) EG.IMP.CONS.ZS NA NA NA NA
## 2 Energy imports, net (% of energy use) EG.IMP.CONS.ZS NA NA NA NA
## 3 Energy imports, net (% of energy use) EG.IMP.CONS.ZS NA NA NA NA
## 4 Energy imports, net (% of energy use) EG.IMP.CONS.ZS NA NA NA NA
## 5 Energy imports, net (% of energy use) EG.IMP.CONS.ZS NA NA NA NA
## 6 Energy imports, net (% of energy use) EG.IMP.CONS.ZS NA NA NA NA
## X1964 X1965 X1966 X1967 X1968 X1969 X1970 X1971 X1972 X1973
## 1 NA NA NA NA NA NA NA NA NA NA
## 2 NA NA NA NA NA NA NA 8.370579 7.817698 7.34956
## 3 NA NA NA NA NA NA NA NA NA NA
## 4 NA NA NA NA NA NA NA -170.260603 -196.227301 -214.97244
## 5 NA NA NA NA NA NA NA -136.789917 -153.693309 -182.75728
## 6 NA NA NA NA NA NA NA -41.699412 -53.634235 -72.51853
## X1974 X1975 X1976 X1977 X1978 X1979
## 1 NA NA NA NA NA NA
## 2 6.113423 6.306606 3.809643 1.114129 0.8703153 -4.265041
## 3 NA NA NA NA NA NA
## 4 -231.992421 -179.047425 -196.601841 -185.836242 -159.8036135 -189.303793
## 5 -187.075367 -176.525499 -173.974390 -166.830017 -130.4909397 -145.520958
## 6 -49.218273 -47.195175 -41.390465 -37.406965 -34.8533229 -50.543975
## X1980 X1981 X1982 X1983 X1984 X1985
## 1 NA NA NA NA NA NA
## 2 -6.223554 -5.99137688 -6.05604 -8.9016572 -12.439199 -16.847877
## 3 NA NA NA NA NA NA
## 4 -163.123696 -111.93610770 -97.75394 -94.8262436 -110.934401 -115.385487
## 5 -147.653492 -124.34030810 -129.53693 -177.1627123 -203.695598 -215.487057
## 6 -12.258246 -0.07642915 1.12903 0.8518419 -2.264095 -3.815862
## X1986 X1987 X1988 X1989 X1990 X1991
## 1 NA NA NA NA NA NA
## 2 -17.203230 -16.693278 -18.5787818 -19.7543357 -21.064620 -20.010178
## 3 NA NA NA NA NA NA
## 4 -110.887748 -97.983800 -104.0178946 -118.5947714 -119.371138 -119.006095
## 5 -263.269771 -331.783550 -403.0892525 -394.3952328 -387.018022 -397.266038
## 6 -3.311196 -2.519564 0.4206107 -0.6568521 7.965058 -2.783624
## X1992 X1993 X1994 X1995 X1996 X1997
## 1 NA NA NA NA NA NA
## 2 -24.052312 -22.80116591 -24.114369 -24.882663 -24.700335 -27.250868
## 3 NA NA NA NA NA NA
## 4 -117.331646 -117.92332970 -123.845113 -121.850438 -126.846206 -133.068882
## 5 -440.718545 -386.72435330 -418.093192 -472.406508 -507.334018 -520.232165
## 6 -3.376251 -0.09775597 9.330732 6.635916 6.291303 8.699857
## X1998 X1999 X2000 X2001 X2002 X2003 X2004
## 1 NA NA NA NA NA NA NA
## 2 -28.90274 -28.44349 -31.39107 -29.13632 -32.91088 -32.41999 -31.16182
## 3 NA NA NA NA NA NA NA
## 4 -126.64396 -115.45560 -120.54223 -118.27119 -98.83530 -108.57220 -111.50833
## 5 -542.37071 -519.35241 -504.15900 -475.11126 -550.71419 -501.43666 -555.80954
## 6 18.41290 40.24967 45.00241 51.68878 53.04410 49.01463 46.00382
## X2005 X2006 X2007 X2008 X2009 X2010 X2011
## 1 NA NA NA NA NA NA NA
## 2 -35.93942 -38.80579 -41.69428 -40.02564 -38.31427 -38.28416 -34.62273
## 3 NA NA NA NA NA NA NA
## 4 -108.52898 -106.88655 -99.31676 -91.94765 -88.70902 -95.40260 -90.77969
## 5 -735.86429 -759.62879 -858.18882 -885.24594 -764.54942 -703.77238 -619.05389
## 6 47.76617 42.37700 47.99839 45.21933 41.66725 23.71398 33.26029
## X2012 X2013 X2014 X2015 X2016 X2017 X2018 X2019 X2020 X2021
## 1 NA NA NA NA NA NA NA NA NA NA
## 2 -32.24499 -32.03501 -31.65543 NA NA NA NA NA NA NA
## 3 NA NA NA NA NA NA NA NA NA NA
## 4 -85.66448 -76.48616 -78.21144 NA NA NA NA NA NA NA
## 5 -589.50613 -594.54614 -540.99747 NA NA NA NA NA NA NA
## 6 16.29787 12.32071 13.79797 NA NA NA NA NA NA NA
## X2022 X2023
## 1 NA NA
## 2 NA NA
## 3 NA NA
## 4 NA NA
## 5 NA NA
## 6 NA NA
plot(energy3$X2005,col=colours(),pch=5,cex=0.5,lwd=3,xlab="Number Of Countries",ylab="Energy imported",main = "En
ergy Imported in 2005")

2 We will now see energy imports of 3 Countries and


compare them over the 45 years
## Australia

a1=energy3[14,5:50]
a2=as.matrix(a1)
barplot(a2,col="darkblue",ylim = c(-150,50),xlim = c(0,50),main = "Energy imported by Australia",xlab = "YEARS",y
lab = "Energy Imported")

## Spain

a3=energy3[71,5:50]
a4=as.matrix(a3)
barplot(a4,col="red",ylim = c(0,80),xlim = c(0,50),main = "Energy imported by Spain",xlab = "YEARS",ylab = "Energ
y Imported")
## Germany

a5=energy3[56,5:50]
a6=as.matrix(a5)
barplot(a6,col="yellow",ylim = c(0,80),xlim = c(0,50),main = "Energy imported by Germany",xlab = "YEARS",ylab = "
Energy Imported")

3 Now we will compare maximum energy imported from


1960 to 2000 (10 years gap)
b1=energy3[,5:50]
b2=subset(data.frame(b1[,1]),b1[,1]>0)
m1=max(b2)
b3=subset(data.frame(b1[,11]),b1[,11]>0)
m2=max(b3)
b4=subset(data.frame(b1[,21]),b1[,21]>0)
m3=max(b4)
b5=subset(data.frame(b1[,31]),b1[,31]>0)
m4=max(b5)
b6=subset(data.frame(b1[,41]),b1[,41]>0)
m5=max(b6)
m6=c(m1,m2,m3,m4,m5)
p1=c(1,2,3,4,5)
names(p1)=c("1960","1970","1980","1990","2000")
p1

## 1960 1970 1980 1990 2000


## 1 2 3 4 5

plot(p1,m6,type = "o",col="red",xlab="YEARS",ylab="Energy Imported",axes=F,ylim = c(95,105),main = "Comparison of


Maximum Energy imported Every 10 years")
axis(side=1,at=1:length(1:5),labels=c("1960","1970","1980","1990","2000"))
axis(side=2)

#Discrepancies that can be seen when comparing 5 years of importing energy of all countries

pairs(energy3[,c(5,50)],col=colours(),pch=7,lwd=1,cex=1,main="Comparison Of Energy Imports for the years 1960 & 2


005")
4 Comparing Boxplot for all countries from the year 1960 to
1970
d1=energy3[,5:15]
boxplot(d1,col="maroon",axes=F,main="Boxplot Of Imports of all Countries from the year 1960 to 1970",xlab="YEARS"
,ylab="Energy Imports")
axis(side=1,at=1:length(1:11),labels=c(1960:1970))
axis(side=2)

quantile(d1,na.rm=T)

## 0% 25% 50% 75% 100%


## -19.71941 17.94188 40.02918 65.51629 99.99493

5 Comparing energy consumption of Luxumbourg ,


Denmark and Greece every 15 years
library(dplyr)

##
## Attaching package: 'dplyr'

## The following objects are masked from 'package:stats':


##
## filter, lag

## The following objects are masked from 'package:base':


##
## intersect, setdiff, setequal, union

Luxembourg=energy3[145,c(5,20,35,50)]
Denmark=energy3[59,c(5,20,35,50)]
Greece=energy3[90,c(5,20,35,50)]
Countries=combine(as.matrix(Luxembourg),as.matrix(Denmark),as.matrix(Greece))

## Warning: `combine()` was deprecated in dplyr 1.0.0.


## ℹ Please use `vctrs::vec_c()` instead.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

rownames(Countries)=c("Luxembourg","Denmark","Greece")
colnames(Countries)=c("1960","1975","1990","2005")
barplot(Countries,beside = T,legend=T,ylim = c(-100,100),xlim=c(0,23),col=c("turquoise","blue","darkblue"),main="
Comparison between Luxembourg , Denmark & Greece",xlab = "YEARS",ylab = "Energy Imported")
abline(h=0,v=0,lwd=3,lty=3)

6 Mean of all countries for the years 1970 - 1980 displayed


in a pie chart
f1=energy3[,15:25]
f2=subset(data.frame(f1$X1970),f1.X1970>0)
length(f1$X1970)

## [1] 266

p1=sum(f2)/266
f3=subset(data.frame(f1$X1971),f1.X1971>0)
length(f1$X1971)
## [1] 266

p2=sum(f3)/266
f4=subset(data.frame(f1$X1972),f1.X1972>0)
length(f1$X1972)

## [1] 266

p3=sum(f4)/266
f5=subset(data.frame(f1$X1973),f1.X1973>0)
length(f1$X1973)

## [1] 266

p4=sum(f5)/266
f6=subset(data.frame(f1$X1974),f1.X1974>0)
length(f1$X1974)

## [1] 266

p5=sum(f6)/266
f7=subset(data.frame(f1$X1975),f1.X1975>0)
length(f1$X1975)

## [1] 266

p6=sum(f7)/266
f8=subset(data.frame(f1$X1976),f1.X1976>0)
length(f1$X1976)

## [1] 266

p7=sum(f8)/266
f9=subset(data.frame(f1$X1977),f1.X1977>0)
length(f1$X1977)

## [1] 266

p8=sum(f9)/266
f10=subset(data.frame(f1$X1978),f1.X1978>0)
length(f1$X1978)

## [1] 266

p9=sum(f10)/266
f11=subset(data.frame(f1$X1979),f1.X1979>0)
length(f1$X1979)

## [1] 266

p10=sum(f11)/266
f12=subset(data.frame(f1$X1980),f1.X1980>0)
length(f1$X1980)

## [1] 266

p11=sum(f12)/266
p12=c(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11)
p13=c("1970","1971","1972","1973","1974","1975","1976","1977","1978","1979","1980")
pie(p12,labels = p13,col=c("lightgreen","green","darkgreen","gold","brown","maroon","red","darkred","darkblue","b
lue","magenta"),clockwise = T,radius=1,main="Pie Chart comparing Mean Imports from 1970 - 1980")
p12

## [1] 7.760886 16.047433 15.864352 16.327239 16.147496 15.579475 16.033769


## [8] 15.995651 15.950212 15.864317 15.567734

7 Comparison Between Energy Imports of India and


Pakistan during 1980 - 1990
g1=energy3[,c(1,25:35)]
g2=g1[c(110,185,41),]
g3=as.matrix(g2[1,])
g4=matrix(g3,ncol = 1)
India=data.frame(g4)
g5=as.matrix(g2[2,])
g6=matrix(g5,ncol = 1)
Pakistan=data.frame(g6)
n3=1:11
g7=as.matrix(g2[3,])
g8=matrix(g7,ncol=1)
China=data.frame(g8)
n1=data.frame(India,Pakistan,China)
colnames(n1)=c("India","Pakistan","China")
n2=n1[-1,]
n4=data.frame(n3,n2)
n5=c("1980","1981","1982","1983","1984","1985","1986","1987","1988","1989","1990")
plot(n4[,1],n4[,2],type = "l",lwd=2,ylim = c(-20,30),col="orange",main = "Comparison between India , China & Paki
stan",xlab = "YEARS",ylab="Energy Imported",axes = F)
axis(side=1,at=1:length(1:11),labels=n5)
axis(side=2)
lines(n4[,1],n4[,3],type = "l",lwd=2,col="darkgreen")
lines(n4[,1],n4[,4],type = "l",lwd=2,col="darkred")
text(x=6,y=25,"Pakistan")
text(x=6,y=10,"India")
text(x=6,y=-2,"China")

You might also like