###Top districts
###Affected by districts
###District vs Age
###scatter point of status vs age
###Box plot of top districts
###Map
###Data Table
###Pivot Table
Created by:Data Scientist @BADHREY Confidential:HIGHLY!
---
title: "Ebola Sierra Leone"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
social:
- Twitter
- Facebook
- Menu
source_code: embed
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning = FALSE, message = FALSE)
library(flexdashboard)
library(ggplot2)
library(ggvis)
library(highcharter)
library(openintro)
library(rpivotTable)
library(dplyr)
library(DT)
library(plotly)
library(knitr)
library("mice")
library(readr)
library(shiny)
```
```{r include=FALSE,echo=FALSE}
ebola_data <- read.csv("C:/Users/hp/Desktop/Project 1.0/Data/ebola_sierra_leone.csv" )
ebola1_data<-mice(ebola_data,n = 5,method =c("","pmm","","","","","") ,maxit = 20)
ebola1_data$imp$age
ebola2_data<-complete(ebola1_data,5)
ebola2_data
```
```{r}
mycolors<-c("blue","red","orange","brown")
```
Interactive Data Visualization
==============================================================
Row
--------------------------------------------------------------
### Siere-leone ebola affectees
```{r}
valueBox(
value = 200,
caption = "Total",
icon = "fa-building",
color=("warning")
)
```
### District affected
```{r}
valueBox(
value = 7,
caption = "Districts Examined",
icon = "fa-building"
)
```
```{r echo=FALSE,include=FALSE}
ebola3_data <- data.frame(district = c("Bo","Kailahun","kambia","kenema","kono","port Loko","western Urban"),
cases = c(2,155,1,34,2,2,4))
cases_by_district <- ebola3_data %>%
group_by(district) %>%
summarise(total_cases = sum(cases))
ebola3_data
```
### Cases in Kailahun
```{r}
fluidRow(
column(4,
valueBox(
value = 155,
caption = "Kailahun",
icon = "fa-building"
)
)
)
```
### cases in B0
```{r}
fluidRow(
column(4,
valueBox(
value = 2,
caption = "Bo",
icon = "fa-building"
)
)
)
```
### Cases in Port Loko
```{r}
fluidRow(
column(4,
valueBox(
value = 2,
caption = "port loko",
icon = "fa-building"
)
)
)
```
### cases in kenema
```{r}
fluidRow(
column(4,
valueBox(
value = 34,
caption = "Kenema",
icon = "fa-building"
)
)
)
```
### cases in kambia
```{r}
fluidRow(
column(4,
valueBox(
value = 1,
caption = "Kambia",
icon = "fa-building"
)
)
)
```
### kono
```{r}
fluidRow(
column(4,
valueBox(
value = 2,
caption = "Kono",
icon = "fa-building"
)
)
)
```
### western urban
```{r}
fluidRow(
column(4,
valueBox(
value = 155,
caption = "Kailahun",
icon = "fa-building"
)
)
)
```
Row
-----------------------------------------------------------------------
###Top districts
```{r}
p1<-ebola2_data %>% group_by(district)%>%summarise(count =n())%>%filter(count>3) %>% plot_ly(labels=~district,values=~count,marker=list(colors=mycolors)) %>% add_pie(hole=0.2) %>% layout(xaxis=list(zeroline=F,Showline=F,showticklabels=F,showgrid=F),yaxis=list(zeroline=F,Showline=F,showticklabels=F,showgrid=F))
p1
```
###Affected by districts
```{r}
p2<-ebola2_data %>% group_by(district)%>%summarise(count =n())%>% plot_ly(x=~district,y=~count,color = "red",type = "bar")%>% layout(xaxis=list(title="Affected by district"),yaxis=list(title="count"))
p2
```
###District vs Age
```{r}
ebola2_data_grouped <- ebola2_data %>%
group_by(age, sex, district) %>%
summarise(count = n())
p3 <- plot_ly(ebola2_data_grouped,
x = ~age,
y = ~count,
color = ~sex,
text = ~paste("District:", district),
type = "bar",
colors = c("red", "blue")) %>%
layout(xaxis = list(title = "Age"),
yaxis = list(title = "Count"),
barmode = "group")
p3
```
Row
------------------------------------------------------------
###scatter point of status vs age
```{r}
color_map <- c(
"M" = "red",
"F" = "blue")
p4 <- plot_ly(ebola2_data,
x = ~age,
y = ~status,
color = ~sex,
colors = color_map,
type = "scatter",
mode = "markers") %>%
layout(xaxis = list(title = "Age"),
yaxis = list(title = "Status"),
title = "Scatter Plot of Age vs. Status by Sex")
p4
p4_interactive <- ggplotly(p4)
```
###Box plot of top districts
```{r}
p5<-ebola2_data %>%
ggplot(aes(x = district, y = age, fill = district)) +
geom_boxplot() +
labs(x = "District", y = "Age", title = "Box Plot of Age by District") +
theme(legend.position = "none")
p5
p5_interactive <- ggplotly(p5)
```
Map
==================================================
###Map
```{r}
treatment<-ebola2_data %>% group_by(district) %>% summarise(total=n())
treatment$district<-abbr2state(treatment$district)
highchart() %>% hc_title(text="ebola ") %>% hc_subtitle(text="source:Ebola treatment.csv") %>% hc_add_series_map(usgeojson,treatment,name="district" ,value = "total",joinBy = c("woename","district")) %>% hc_mapNavigation(enabled=T)
```
Data Table
======================================================
###Data Table
```{r}
datatable(ebola2_data,caption = "Affected Data",rownames = T,filter = "top",options = list(pagelength=25))
```
Pivot Table
=====================================================
###Pivot Table
```{r}
rpivotTable(ebola2_data,aggregatorName = "count",cols = "count",rows = "district",rendererName = "Heatmap")
```
About Report
=======================================================
Created by:Data Scientist @BADHREY
Confidential:HIGHLY!