AED Kelasc 06211840000019
AED Kelasc 06211840000019
Dari grafik tersebut, semakin besar populasi di suatu negara, maka jumlah kasus
terkonfirmasinya akan cenderung meningkat.
Nauli Mazaya Siregar (06211840000019)
Sama seperti sebelumnya, United States memiliki jumlah kasus terkonfirmasi terbanyak
dibandingkan dengan jumlah kasus negara lain di kelompoknya. Jika diruntut, jumlah
kasus terkonfirmasi di United States adalah 1347916 kasus.
Di bawah ini adalah plot korelasi untuk populasi dan total kasus terkonfirmasi di
negara-negara kelompok A.
Tidak berbeda jauh dengan poin sebelumnya, di negara kelompok A total kasus
terkonfirmasi juga cenderung meningkat seiring dengan besarnya populasi di suatu
negara.
Nauli Mazaya Siregar (06211840000019)
Agak berbeda dengan sebelumnya di mana ketika semakin besar populasi maka
semakin banyak kasusnya, di negara kelompok B justru ada anomali. Di titik populasi
besar, jumlah kasus mulai turun. Hal ini dikarenakan kasus terbanyak ada di Singapore
sementara populasi masyarakat di Singapore tidaklah besar. Asumsi saya, populasi
terbesar di plot tersebut adalah negara Indonesia.
2. Variabel jumlah kematian
a. Dari negara kelompok A dan B
Sebanding dengan jumlah kasus terkonfirmasinya, United States juga memiliki angka
kematian yang paling tinggi, sekitar 80684 kematian disusul dengan United Kingdom di
angka 32065 kematian.
Di bawah ini adalah plot korelasi total kasus terkonfirmasi dan total kematian di negara-
negara terpilih.
Nauli Mazaya Siregar (06211840000019)
Berbeda dengan biasanya, plot tersebut justru menampilkan kurva kuadratik angka
kematian memiliki puncak justru di nilai tengah jumlah kasus positif. Ketika jumlah
kasus positif sudah semakin banyak, angka kematian justru menurun.
Nauli Mazaya Siregar (06211840000019)
Fakta menarik bahwa semakin kesini plot justru menampilkan kurva kuadratik. Angka
kematian tertinggi berkisar di jumlah kasus positif sebesar 15000. Saya berasumsi
ketika suatu negara memiliki kasus positif yang banyak, negara tersebut justru akan
paham betul bagaimana cara mengatasinya dengan pengalaman dari kasus-kasus
sebelumnya. Oleh karena itu, ketika jumlah kasus positif semakin banyak, angka
kematiannya justru menurun.
Nauli Mazaya Siregar (06211840000019)
16 19082.62
17 35220.08
18 24765.95
19 25129.34
20 54225.45
> ggplot(data,aes(x=data$total_cases,y=data$total_deaths))
+geom_smooth(method="loess",se=F)+labs(subtitle="Cases vs Deaths",y="jumlah
meninggal",x="jumlah kasus positif")
> ggplot(data,aes(x=dataB$total_cases,y=dataB$total_deaths))
+geom_smooth(method="loess",se=F)+labs(subtitle="Cases vs Deaths (negara
ASEAN)",y="jumlah meninggal",x="jumlah kasus positif")
Error: Aesthetics must be either length 1 or the same as the data (20): x, y
> dataB
Kelompok location total_cases total_deaths total_deaths_per_million population
1 B Brunei 141 1 2.286 437483
2 B Indonesia 14265 991 3.623 273523621
3 B Cambodia 122 0 0.000 16718971
4 B Laos 19 0 0.000 7275556
5 B Myanmar 180 6 0.110 54409794
6 B Malaysia 6726 109 3.368 32365998
7 B Philippines 11086 726 6.625 109581085
8 B Singapore 23787 21 3.590 5850343
9 B Thailand 3015 56 0.802 69799978
10 B Vietnam 288 0 0.000 97338583
gdp_per_capita
1 71809.251
2 11188.744
3 3645.070
4 6397.360
Nauli Mazaya Siregar (06211840000019)
5 5591.597
6 26808.164
7 7599.188
8 85535.383
9 16277.671
10 6171.884
> ggplot(dataB,aes(x=dataB$total_cases,y=dataB$total_deaths))
+geom_smooth(method="loess",se=F)+labs(subtitle="Cases vs Deaths (negara
ASEAN)",y="jumlah meninggal",x="jumlah kasus positif")
> ggplot(dataA,aes(x=dataA$total_cases,y=dataA$total_deaths))
+geom_smooth(method="loess",se=F)+labs(subtitle="Cases vs Deaths (negara
kelompok A)",y="jumlah meninggal",x="jumlah kasus positif")
> ggplot(data,aes(x=as.factor(data$Kelompok),y=total_deaths))+geom_violin()
> ggplot(data,aes(x=as.factor(data$Kelompok),y=total_deaths))+geom_boxplot()
> hist(total_deaths)
Error in hist(total_deaths) : object 'total_deaths' not found
> hist(data$total_deaths)
> barplot(data$total_deaths,names.arg=data$location)
> barplot(data$total_deaths,names.arg=data$location)
> barplot(dataA$total_deaths,names.arg=dataA$location)
> barplot(dataB$total_deaths,names.arg=dataB$location)
> ggplot(data,aes(x=data$population,y=dataa$total_cases))
+geom_smooth(method="loess",se=F)+labs(subtitle="Population vs Cases",y="jumlah
kasus positif",x="populasi")
Error in FUN(X[[i]], ...) : object 'dataa' not found
> ggplot(data,aes(x=data$population,y=data$total_cases))
+geom_smooth(method="loess",se=F)+labs(subtitle="Population vs Cases",y="jumlah
kasus positif",x="populasi")
> ggplot(dataB,aes(x=dataB$population,y=dataB$total_cases))
+geom_smooth(method="loess",se=F)+labs(subtitle="Population vs Cases (negara
ASEAN)",y="jumlah kasus positif",x="populasi")
Nauli Mazaya Siregar (06211840000019)
> dataB
Kelompok location total_cases total_deaths total_deaths_per_million population
1 B Brunei 141 1 2.286 437483
2 B Indonesia 14265 991 3.623 273523621
3 B Cambodia 122 0 0.000 16718971
4 B Laos 19 0 0.000 7275556
5 B Myanmar 180 6 0.110 54409794
6 B Malaysia 6726 109 3.368 32365998
7 B Philippines 11086 726 6.625 109581085
8 B Singapore 23787 21 3.590 5850343
9 B Thailand 3015 56 0.802 69799978
10 B Vietnam 288 0 0.000 97338583
gdp_per_capita
1 71809.251
2 11188.744
3 3645.070
4 6397.360
5 5591.597
6 26808.164
7 7599.188
8 85535.383
9 16277.671
10 6171.884
> ggplot(dataA,aes(x=dataA$population,y=dataA$total_cases))
+geom_smooth(method="loess",se=F)+labs(subtitle="Population vs Cases (negara
kelompok A)",y="jumlah kasus positif",x="populasi")
> p=ggplot(data,aes(x=data$population,y=data$total_cases))
+geom_smooth(method="loess",se=F)+labs(subtitle="Population vs Cases",y="jumlah
kasus positif",x="populasi")
Nauli Mazaya Siregar (06211840000019)
> fig=ggplotly(p)
Error in ggplotly(p) : could not find function "ggplotly"
> library(plotly)
last_plot
filter
layout
Warning message:
package ‘plotly’ was built under R version 3.6.3
> fig=ggplotly(p)
> fig=ggplotly(p)
> library(gapminder)
Warning message:
package ‘gapminder’ was built under R version 3.6.3
> fig=ggplotly(p)
> df=data.frame(x=c(1,2,3,4),y=c(1,2,3,4),f=c(1,2,3,4))
> p=ggplot(df,aes(x,y))
Nauli Mazaya Siregar (06211840000019)
> fig
> fig
> p=ggplot(data,aes(x=data$population,y=data$total_cases))
+geom_smooth(method="loess",se=F)+labs(subtitle="Population vs Cases",y="jumlah
kasus positif",x="populasi")
> fig=ggplotly(p)%>%animation_opts(1000,easing="elastic",redraw=FALSE)%>
%animation_button(x=1,xanchor="right",y=0,yanchor="bottom")%>
%animation_slider(currentvalue=list(prefix("Population vs
Cases"),font=list(color="red")))
Error in p$x$layout$updatemenus[[which(isAniButton)]] <-
modify_list(p$x$layout$updatemenus[[which(isAniButton)]], :
attempt to select less than one element in OneIndex
> fig=ggplotly(p)%>%animation_opts(1000,easing="elastic",redraw=FALSE)%>
%animation_slider(currentvalue=list(prefix("Population vs
Cases"),font=list(color="red")))
Error in prefix("Population vs Cases") : could not find function "prefix"
> fig=ggplotly(p)%>%animation_opts(1000,easing="elastic",redraw=FALSE)
> fig
> p=ggplot(df,aes(x,y))
> fig=ggplotly(p)
> fig
> p=ggplot(df,aes(x,y))+geom_point(aes(frame=f))
Warning: Ignoring unknown aesthetics: frame
> fig=ggplotly(p)
> fig
> f=c(1:1347916)
> p=ggplot(data,aes(x=data$population,y=data$total_cases))
+geom_smooth(method="loess",se=F)+labs(subtitle="Population vs Cases",y="jumlah
kasus positif",x="populasi")+geom_point(aes(frame=f))
Warning: Ignoring unknown aesthetics: frame
> fig=ggplotly(p)
Nauli Mazaya Siregar (06211840000019)
Error: Aesthetics must be either length 1 or the same as the data (20): frame
> p=ggplot(data,aes(x=data$population,y=data$total_cases))
+geom_smooth(method="loess",se=F)+labs(subtitle="Population vs Cases",y="jumlah
kasus positif",x="populasi")+geom_point(aes(frame=f))
Warning: Ignoring unknown aesthetics: frame
> f=c(1:20)
> p=ggplot(data,aes(x=data$population,y=data$total_cases))
+geom_smooth(method="loess",se=F)+labs(subtitle="Population vs Cases",y="jumlah
kasus positif",x="populasi")+geom_point(aes(frame=f))
Warning: Ignoring unknown aesthetics: frame
> fig=ggplotly(p)
> fig
> q=ggplot(data,aes(x=data$total_cases,y=data$total_deaths))
+geom_smooth(method="loess",se=F)+labs(subtitle="Cases vs Deaths",y="jumlah
meninggal",x="jumlah kasus positif")+geom_point(aes(frame=f))
Warning: Ignoring unknown aesthetics: frame
> figg=ggplotly(f)
Error in UseMethod("ggplotly", p) :
no applicable method for 'ggplotly' applied to an object of class "c('integer', 'numeric')"
> p=ggplot(data,aes(x=data$total_cases,y=data$total_deaths))
+geom_smooth(method="loess",se=F)+labs(subtitle="Cases vs Deaths",y="jumlah
meninggal",x="jumlah kasus positif")+geom_point(aes(frame=f))
Warning: Ignoring unknown aesthetics: frame
> figg=ggplotly(p)
> figg
> fig
> n=10
> h=0.1
> x=c(seq(0,991,by=0.1))
> q=dataB[,4]
> x1=t(q)
Nauli Mazaya Siregar (06211840000019)
> a=n*h
> k=1/a
> for(i in 1:n){
+ k[i]=0.75*k*(1-((x-x1[i])/h)^2)}
There were 18 warnings (use warnings() to see them)
> jumlah=0
> for(i in 1:n){
+ jumlah=jumlah+k[i]}
> df=tbl_df(data.frame(x,k[],jumlah))
Error in data.frame(x, k[], jumlah) :
arguments imply differing number of rows: 9911, 10, 1
> df=tbl_df(data.frame(x,k[1],k[2],k[3],k[4],k[5],k[6],k[7],k[8],k[9],k[10],jumlah))
> df%>%
+ ggplot(aes(x=x,y=k[1]))+geom_line()+geom_line(y=k[2])+geom_line(y=k[3])
+geom_line(y=k[4])+geom_line(y=k[5])+geom_line(y=k[6])+geom_line(y=k[7])
+geom_line(y=k[8])+geom_line(y=k[9])+geom_line(y=k[10])+geom_line(y=jumlah)
>
Nauli Mazaya Siregar (06211840000019)