-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml-tabs.Rmd
134 lines (98 loc) · 3.57 KB
/
html-tabs.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
---
title: "Theming with bslib and thematic"
output:
pdf_document: default
html_document:
code_folding: show
theme:
bg: '#202123'
fg: '#B8BCC2'
primary: '#EA80FC'
secondary: '#00DAC6'
base_font:
google: Prompt
heading_font:
google: Proza Libre
---
```{r setup, include=FALSE}
if (requireNamespace("thematic"))
thematic::thematic_rmd(font = "auto")
#packages for data manipulation
library(readr)
library(dplyr)
library(plyr)
library(sf)
library(rAmCharts)
```
```{r, include=FALSE}
#loading COVID-19 India data and filtering for 1st oct 2021
data_whole<-read.csv("states.csv")
data_ex <- read_csv("states.csv")%>%
filter(Date=="2021-10-01")%>%
filter(State!="India")%>%
select(c("State","Confirmed"))%>%
arrange(State)
State <- as.character(data_ex$State)
```
```{r, include=F,echo=F,message=FALSE,error=F,warning=F}
#loading shape file and merging with covid19 data
map_data <- read_sf("India_State_Shapefile/India_State_Shapefile/India_State_Boundary.shp")%>%
arrange(Name)%>%
cbind(State,.)%>%
merge(.,data_ex,by="State")%>%
st_as_sf()
```
```{r, echo=FALSE,include=F}
#loading packages to build map
library(tmap)
library(tmaptools)
pal=get_brewer_pal("-RdYlGn", n = 5,contrast = c(0.4,1))
```
# COVID-19 India Map
I have made a statc and a interective map of India to visualize COVID-19 confirmed cases in India state wise as of 1st october 2021. Chechout the tabs:-
## Themed Plots {.tabset .tabset-pills}
### Static Map
```{r,echo=FALSE,include=F}
#building static map
map_static<-tm_shape(map_data) +
tm_fill(col = "Confirmed",style = "quantile", alpha=1, palette = pal)+
tm_bubbles(size = "Confirmed",col="Confirmed",palette="Greys")+
tm_text("State",remove.overlap=T, size=0.5)+
tm_borders(col="grey",lwd=1, alpha = 1)+
tm_layout(frame = F)+
tm_compass(type = "4star",show.labels = 1,size=2, position = c("left", "bottom"))+
tm_credits("Source: https://www.covid19india.org/",position = c("left", "bottom"))+
tm_legend(legend.outside=T,legend.outside.position=c("right","bottom"),title="Total Confirmed Cases")
tmap_mode("plot")
```
#### COVID-19 India Confirmed Cases As Of 1 Oct 2021
```{r, echo=FALSE,include=T,message=FALSE,error=F,warning=F}
#ploting the Static Map
map_static
```
### Time Series
```{r, out.length="100%", out.width="100%"}
date<-data_whole$Date %>% as.Date() %>% as.POSIXct()
data_whole<-cbind(date,data_whole)
states <- as.character(unique(data_whole$State))
India <- data_whole%>%subset(., State == "India")
amTimeSeries(India, 'date', c('Confirmed', 'Recovered','Deceased'),bullet = 'round',linewidth = c(3,3,3),group = 'State', main = "Covid cases time series")
```
### Interective Map
```{r, echo=FALSE,include=F}
#building the interective map
map_interective<-tm_shape(map_data) +
tm_fill(col = "Confirmed",style = "quantile", alpha=1, palette = pal,popup.vars = c("State","Confirmed"))+
tm_bubbles(size = "Confirmed",col = "Confirmed",interactive=T,popup.vars="Confirmed",palette="Greys",legend.size.show=F)+
tm_text("State",size=0.5)+
tm_borders(col="grey",lwd=1,alpha = 0.5)+
tm_layout(frame = T, outer.margins = 0, inner.margins = 0,bg.color="lightblue")+
tm_view(set.view = 4, alpha = 1, set.zoom.limits=c(3,8),view.legend.position=c("right","top") )+
tm_legend(legend.outside=T,legend.outside.position=c("right","bottom"),title="Total Confirmed Cases")
tmap_mode("view")
```
#### COVID-19 India Confirmed Cases As Of 1 Oct 2021
```{r, echo=FALSE,include=T,out.length="100%", out.width="100%"}
#ploting the Interective COVID-19 India Map
map_interective
```