TOTAL

Column

Confirmed Cases (daily)

Column

Recovered Cases (cumulative)

Death Cases (cumulative)

Column

lastupdate

2020-03-22

confirmed

335,955

active

223,619 (66.6%)

recovered

97,704 (29.1%)

death

14,632 (4.4%)

TOTAL (b)

Active, recovered and death cases over time (cumulative cases)

China

Column

Confirmed Cases (daily)

Column

Recovered Cases (cumulative)

Death Cases (cumulative)

Column

confirmed

81,397

active

5,770

recovered

72,362

death

3,265

China (b)

Active, recovered and death cases over time (cumulative cases)

Spain

Column

Confirmed Cases (daily)

Column

Recovered Cases (cumulative)

Death Cases (cumulative)

Column

confirmed

28,768

active

24,421

recovered

2,575

death

1,772

Spain (b)

Active, recovered and death cases over time (cumulative cases)

Italy

Column

Confirmed Cases (daily)

Column

Recovered Cases (cumulative)

Death Cases (cumulative)

Column

confirmed

59,138

active

46,638

recovered

7,024

death

5,476

Italy (b)

Active, recovered and death cases over time (cumulative cases)

France

Column

Confirmed Cases (daily)

Column

Recovered Cases (cumulative)

Death Cases (cumulative)

Column

confirmed

16,176

active

13,296

recovered

2,206

death

674

France (b)

Active, recovered and death cases over time (cumulative cases)

South Korea

Column

Confirmed Cases (daily)

Column

Recovered Cases (cumulative)

Death Cases (cumulative)

Column

confirmed

8,897

active

5,884

recovered

2,909

death

104

South Korea (b)

Active, recovered and death cases over time (cumulative cases)

Iran

Column

Confirmed Cases (daily)

Column

Recovered Cases (cumulative)

Death Cases (cumulative)

Column

confirmed

21,638

active

12,022

recovered

7,931

death

1,685

Iran (b)

Active, recovered and death cases over time (cumulative cases)

United Kingdom

Column

Confirmed Cases (daily)

Column

Recovered Cases (cumulative)

Death Cases (cumulative)

Column

confirmed

5,741

active

5,392

recovered

67

death

282

United Kingdom (b)

Active, recovered and death cases over time (cumulative cases)

United States

Column

Confirmed Cases (daily)

Column

Recovered Cases (cumulative)

Death Cases (cumulative)

Column

confirmed

33,272

active

32,855

recovered

0

death

417

United States (b)

Active, recovered and death cases over time (cumulative cases)

---
title: "Coronavirus (II)"
author: "Rubén F. Bustillo"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
    vertical_layout: fill
    theme: cerulean
---



```{r setup, include=FALSE}

#------------------ paquetes ------------------

devtools::install_github("RamiKrispin/coronavirus")
coronavirus<-coronavirus::coronavirus

library(flexdashboard)
library(coronavirus)
library(tidyverse)
library(echarts4r)
library(DT)
library(plotly)


data(coronavirus)


# COLORES:

# https://www.w3.org/TR/css-color-3/#svg-color

confirmed_color <- "lightsteelblue"
active_color <- "orange"
recovered_color <- "limegreen"
death_color <- "red"



# DATASETS:

# CORONAVIRUS DATASET 

coronavirus_b <- coronavirus %>%
  mutate(country = recode_factor(Country.Region,
                                 "Czechia"= "Czech Rep.",
                                 "United Arab Emirates" = "UAE",
                                 "Bosnia and Herzegovina"= "Bosnia and Herz.",
                                 "Korea, South" = "Korea",
                                 "Dominican Republic" = "Dominican Rep.",
                                 "Faroe Islands" = "Faeroe Is.",
                                 "North Macedonia" = "Macedonia",
                                 "occupied Palestinian territory" = "Palestine",
                                 "Congo (Kinshasa)" = "Dem. Rep. Congo",
                                 "Cote d'Ivoire"= "Côte d’Ivoire",
                                 "Republic of Moldova" = "Moldova"))


# CASES by country

df <- coronavirus %>% 
  group_by(Country.Region, type) %>%
  summarise(total = sum(cases)) %>%
  pivot_wider(names_from =  type, 
              values_from = total) %>%
  mutate(unrecovered = confirmed - ifelse(is.na(recovered), 0, recovered) - ifelse(is.na(death), 0, death)) %>%
  arrange(-confirmed) %>%
  ungroup() %>%
  mutate(country = recode_factor(Country.Region,
                                 "Czechia"= "Czech Rep.",
                                 "United Arab Emirates" = "UAE",
                                 "Bosnia and Herzegovina"= "Bosnia and Herz.",
                                 "Korea, South" = "Korea",
                                 "Dominican Republic" = "Dominican Rep.",
                                 "Faroe Islands" = "Faeroe Is.",
                                 "North Macedonia" = "Macedonia",
                                 "occupied Palestinian territory" = "Palestine",
                                 "Congo (Kinshasa)" = "Dem. Rep. Congo",
                                 "Cote d'Ivoire"= "Côte d’Ivoire",
                                 "Republic of Moldova" = "Moldova"))


# CUMULATIVE CASES:

df_daily <- coronavirus %>% 
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = TRUE)) %>%
  pivot_wider(names_from = type,
                     values_from = total) %>%
  arrange(date) %>%
  ungroup() %>%
  mutate(active =  confirmed - death - recovered) %>%
  mutate(confirmed_cumulative = cumsum(confirmed),
                death_cumulative = cumsum(death),
                recovered_cumulative = cumsum(recovered),
                active_cumulative = cumsum(active))
  
df1 <- coronavirus %>% 
  filter(date == max(date))


```


TOTAL
=======================================================================

```{r, include=FALSE}

df_total <- coronavirus_b %>% 
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = F)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  arrange(date) %>%
  ungroup() 

```

Column
-------------------------------------

### 

```{r, figh.height = 10}

df_table <- df %>%
  select(country, confirmed, recovered, death)

df_table %>%
  datatable(rownames = FALSE)

```

### Confirmed Cases (daily)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_total) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ confirmed,
                    type = "bar",
                    line = list(color = confirmed_color),
                    marker = list(color = confirmed_color)) %>%
  plotly::layout(yaxis = list(title = "Confirmed Cases"),
                 xaxis = list(title = ""))

```

Column 
-------------------------------------
    
### Recovered Cases (cumulative)
    

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::layout(yaxis = list(title = "Recovered Cases (cumulative)"),
                 xaxis = list(title = ""))

```  
   
### Death Cases (cumulative)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::layout(yaxis = list(title = "Death Cases (cumulative)"),
                 xaxis = list(title = ""))


``` 
   
Column 
-------------------------------------

### lastupdate {.value-box}

```{r}

valueBox(value = head(df1$date, n=1), 
         caption = "Last update")
```  
   
### confirmed {.value-box}

```{r}

valueBox(value = paste(format(sum(df$confirmed), big.mark = ","), "", sep = " "), 
         caption = "Total Confirmed Cases", 
         color = confirmed_color)
```


### active {.value-box}

```{r}

valueBox(value = paste(format(sum(df$unrecovered, na.rm = TRUE), big.mark = ","), 
                       " (", round(100 * sum(df$unrecovered, na.rm = TRUE) / sum(df$confirmed), 1), 
                       "%)", sep = ""), 
         caption = "Active Cases",  
         color = active_color)
```

### recovered {.value-box}

```{r}

valueBox(value = paste(format(sum(df$recovered, na.rm = TRUE), big.mark = ","), 
                       " (", round(100 * sum(df$recovered, na.rm = TRUE) / sum(df$confirmed), 1), 
                       "%)", sep = ""), 
         caption = "Recovered Cases", 
         color = recovered_color)
```

### death {.value-box}

```{r}

valueBox(value = paste(format(sum(df$death, na.rm = TRUE), big.mark = ","), 
                       " (", round(100 * sum(df$death, na.rm = TRUE) / sum(df$confirmed), 1), 
                       "%)", sep = ""),
         caption = "Death Cases", 
         color = death_color)

```      
      

TOTAL (b)
=======================================================================

### Active, recovered and death cases over time (cumulative cases)

```{r}

plotly::plot_ly(data = df_daily) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ active_cumulative,
                    type = "bar",
                    name = "Active",
                    line = list(color = active_color),
                    marker = list(color = active_color)) %>%
  plotly::layout(barmode = 'stack',
                 yaxis = list(title = "Total Cases"),
                 xaxis = list(title = ""),
                 hovermode = "compare")
  
  

```

    

China
=======================================================================

```{r, include=FALSE}

df_china <- coronavirus_b %>% 
  filter(country == "China") %>%
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = F)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  arrange(date) %>%
  ungroup()

coronavirus_china <- coronavirus_b %>%
  filter (country == "China")

df_china_valuebox<-df %>%
  filter (country == "China")

df_daily_china  <- coronavirus_china %>% 
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = TRUE)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  mutate_if(is.numeric, ~replace(., is.na(.),0)) %>%
  arrange(date) %>%
  ungroup() %>%
  mutate(active =  confirmed - death - recovered) %>%
  mutate(confirmed_cumulative = cumsum(confirmed),
         death_cumulative = cumsum(death),
         recovered_cumulative = cumsum(recovered),
         active_cumulative = cumsum(active))

```

Column
-------------------------------------

### 

```{r, figh.height = 10}

df_china %>%
  datatable(rownames = FALSE)

```

### Confirmed Cases (daily)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_china) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ confirmed,
                    type = "bar",
                    line = list(color = confirmed_color),
                    marker = list(color = confirmed_color)) %>%
  plotly::layout(yaxis = list(title = "Confirmed Cases"),
                 xaxis = list(title = ""))

```

Column 
-------------------------------------
    
### Recovered Cases (cumulative)
    

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_china) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::layout(yaxis = list(title = "Recovered Cases (cumulative)"),
                 xaxis = list(title = ""))

```  
   
### Death Cases (cumulative)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_china) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::layout(yaxis = list(title = "Death Cases (cumulative)"),
                 xaxis = list(title = ""))


``` 
   
Column 
-------------------------------------
   
### confirmed {.value-box}

```{r}

valueBox(value = paste(format(sum(df_china_valuebox$confirmed), big.mark = ","), "", sep = " "), 
         caption = "Confirmed Cases", 
         color = confirmed_color)
```


### active {.value-box}

```{r}

valueBox(value = paste(format(sum(df_china_valuebox$unrecovered), big.mark = ","), "", sep = " "), 
         caption = "Active Cases",  
         color = active_color)
```

### recovered {.value-box}

```{r}

valueBox(value = paste(format(sum(df_china_valuebox$recovered), big.mark = ","), "", sep = " "), 
         caption = "Recovered Cases", 
         color = recovered_color)
```

### death {.value-box}

```{r}

valueBox(value = paste(format(sum(df_china_valuebox$death), big.mark = ","), "", sep = " "),
         caption = "Death Cases", 
         color = death_color)

```
  
China (b)
=======================================================================

### Active, recovered and death cases over time (cumulative cases)

```{r}

plotly::plot_ly(data = df_daily_china) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ active_cumulative,
                    type = "bar",
                    name = "Active",
                    line = list(color = active_color),
                    marker = list(color = active_color)) %>%
  plotly::layout(barmode = 'stack',
                 yaxis = list(title = "Total Cases"),
                 xaxis = list(title = ""),
                 hovermode = "compare")
  
  

```

Spain
=======================================================================

```{r, include=FALSE}

df_spain <- coronavirus_b %>% 
  filter(country == "Spain") %>%
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = F)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  arrange(date) %>%
  ungroup()

coronavirus_spain <- coronavirus_b %>%
  filter (country == "Spain")

df_spain_valuebox<-df %>%
  filter (country == "Spain")

df_daily_spain  <- coronavirus_spain %>% 
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = TRUE)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  mutate_if(is.numeric, ~replace(., is.na(.),0)) %>%
  arrange(date) %>%
  ungroup() %>%
  mutate(active =  confirmed - death - recovered) %>%
  mutate(confirmed_cumulative = cumsum(confirmed),
         death_cumulative = cumsum(death),
         recovered_cumulative = cumsum(recovered),
         active_cumulative = cumsum(active))

```

Column
-------------------------------------

### 

```{r, figh.height = 10}

df_spain %>%
  datatable(rownames = FALSE)

```

### Confirmed Cases (daily)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_spain) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ confirmed,
                    type = "bar",
                    line = list(color = confirmed_color),
                    marker = list(color = confirmed_color)) %>%
  plotly::layout(yaxis = list(title = "Confirmed Cases"),
                 xaxis = list(title = ""))

```

Column 
-------------------------------------
    
### Recovered Cases (cumulative)
    

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_spain) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::layout(yaxis = list(title = "Recovered Cases (cumulative)"),
                 xaxis = list(title = ""))

```  
   
### Death Cases (cumulative)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_spain) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::layout(yaxis = list(title = "Death Cases (cumulative)"),
                 xaxis = list(title = ""))


``` 
   
Column 
-------------------------------------
   
### confirmed {.value-box}

```{r}

valueBox(value = paste(format(sum(df_spain_valuebox$confirmed), big.mark = ","), "", sep = " "), 
         caption = "Confirmed Cases", 
         color = confirmed_color)
```


### active {.value-box}

```{r}

valueBox(value = paste(format(sum(df_spain_valuebox$unrecovered), big.mark = ","), "", sep = " "), 
         caption = "Active Cases",  
         color = active_color)
```

### recovered {.value-box}

```{r}

valueBox(value = paste(format(sum(df_spain_valuebox$recovered), big.mark = ","), "", sep = " "), 
         caption = "Recovered Cases", 
         color = recovered_color)
```

### death {.value-box}

```{r}

valueBox(value = paste(format(sum(df_spain_valuebox$death), big.mark = ","), "", sep = " "),
         caption = "Death Cases", 
         color = death_color)

```


Spain (b)
=======================================================================

### Active, recovered and death cases over time (cumulative cases)

```{r}

plotly::plot_ly(data = df_daily_spain) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ active_cumulative,
                    type = "bar",
                    name = "Active",
                    line = list(color = active_color),
                    marker = list(color = active_color)) %>%
  plotly::layout(barmode = 'stack',
                 yaxis = list(title = "Total Cases"),
                 xaxis = list(title = ""),
                 hovermode = "compare")
  
  

```  

Italy
=======================================================================

```{r, include=FALSE}

df_italy <- coronavirus_b %>% 
  filter(country == "Italy") %>%
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = F)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  arrange(date) %>%
  ungroup()

coronavirus_italy <- coronavirus_b %>%
  filter (country == "Italy")

df_italy_valuebox<-df %>%
  filter (country == "Italy")

df_daily_italy  <- coronavirus_italy %>% 
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = TRUE)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  mutate_if(is.numeric, ~replace(., is.na(.),0)) %>%
  arrange(date) %>%
  ungroup() %>%
  mutate(active =  confirmed - death - recovered) %>%
  mutate(confirmed_cumulative = cumsum(confirmed),
         death_cumulative = cumsum(death),
         recovered_cumulative = cumsum(recovered),
         active_cumulative = cumsum(active))

```

Column
-------------------------------------

### 

```{r, figh.height = 10}

df_italy %>%
  datatable(rownames = FALSE)

```

### Confirmed Cases (daily)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_italy) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ confirmed,
                    type = "bar",
                    line = list(color = confirmed_color),
                    marker = list(color = confirmed_color)) %>%
  plotly::layout(yaxis = list(title = "Confirmed Cases"),
                 xaxis = list(title = ""))

```

Column 
-------------------------------------
    
### Recovered Cases (cumulative)
    

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_italy) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::layout(yaxis = list(title = "Recovered Cases (cumulative)"),
                 xaxis = list(title = ""))

```  
   
### Death Cases (cumulative)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_italy) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::layout(yaxis = list(title = "Death Cases (cumulative)"),
                 xaxis = list(title = ""))


``` 
   
Column 
-------------------------------------
   
### confirmed {.value-box}

```{r}

valueBox(value = paste(format(sum(df_italy_valuebox$confirmed), big.mark = ","), "", sep = " "), 
         caption = "Confirmed Cases", 
         color = confirmed_color)
```


### active {.value-box}

```{r}

valueBox(value = paste(format(sum(df_italy_valuebox$unrecovered), big.mark = ","), "", sep = " "), 
         caption = "Active Cases",  
         color = active_color)
```

### recovered {.value-box}

```{r}

valueBox(value = paste(format(sum(df_italy_valuebox$recovered), big.mark = ","), "", sep = " "), 
         caption = "Recovered Cases", 
         color = recovered_color)
```

### death {.value-box}

```{r}

valueBox(value = paste(format(sum(df_italy_valuebox$death), big.mark = ","), "", sep = " "),
         caption = "Death Cases", 
         color = death_color)

```
  
Italy (b)
=======================================================================

### Active, recovered and death cases over time (cumulative cases)

```{r}

plotly::plot_ly(data = df_daily_italy) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ active_cumulative,
                    type = "bar",
                    name = "Active",
                    line = list(color = active_color),
                    marker = list(color = active_color)) %>%
  plotly::layout(barmode = 'stack',
                 yaxis = list(title = "Total Cases"),
                 xaxis = list(title = ""),
                 hovermode = "compare")
  
  

```  


France
=======================================================================

```{r, include=FALSE}

df_france <- coronavirus_b %>% 
  filter(country == "France") %>%
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = F)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  arrange(date) %>%
  ungroup()

coronavirus_france <- coronavirus_b %>%
  filter (country == "France")

df_france_valuebox<-df %>%
  filter (country == "France")

df_daily_france  <- coronavirus_france %>% 
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = TRUE)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  mutate_if(is.numeric, ~replace(., is.na(.),0)) %>%
  arrange(date) %>%
  ungroup() %>%
  mutate(active =  confirmed - death - recovered) %>%
  mutate(confirmed_cumulative = cumsum(confirmed),
         death_cumulative = cumsum(death),
         recovered_cumulative = cumsum(recovered),
         active_cumulative = cumsum(active))

```

Column
-------------------------------------

### 

```{r, figh.height = 10}

df_france %>%
  datatable(rownames = FALSE)

```

### Confirmed Cases (daily)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_france) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ confirmed,
                    type = "bar",
                    line = list(color = confirmed_color),
                    marker = list(color = confirmed_color)) %>%
  plotly::layout(yaxis = list(title = "Confirmed Cases"),
                 xaxis = list(title = ""))

```

Column 
-------------------------------------
    
### Recovered Cases (cumulative)
    

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_france) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::layout(yaxis = list(title = "Recovered Cases (cumulative)"),
                 xaxis = list(title = ""))

```  
   
### Death Cases (cumulative)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_france) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::layout(yaxis = list(title = "Death Cases (cumulative)"),
                 xaxis = list(title = ""))


``` 
   
Column 
-------------------------------------
   
### confirmed {.value-box}

```{r}

valueBox(value = paste(format(sum(df_france_valuebox$confirmed), big.mark = ","), "", sep = " "), 
         caption = "Confirmed Cases", 
         color = confirmed_color)
```


### active {.value-box}

```{r}

valueBox(value = paste(format(sum(df_france_valuebox$unrecovered), big.mark = ","), "", sep = " "), 
         caption = "Active Cases",  
         color = active_color)
```

### recovered {.value-box}

```{r}

valueBox(value = paste(format(sum(df_france_valuebox$recovered), big.mark = ","), "", sep = " "), 
         caption = "Recovered Cases", 
         color = recovered_color)
```

### death {.value-box}

```{r}

valueBox(value = paste(format(sum(df_france_valuebox$death), big.mark = ","), "", sep = " "),
         caption = "Death Cases", 
         color = death_color)

```
  
France (b)
=======================================================================

### Active, recovered and death cases over time (cumulative cases)

```{r}

plotly::plot_ly(data = df_daily_france) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ active_cumulative,
                    type = "bar",
                    name = "Active",
                    line = list(color = active_color),
                    marker = list(color = active_color)) %>%
  plotly::layout(barmode = 'stack',
                 yaxis = list(title = "Total Cases"),
                 xaxis = list(title = ""),
                 hovermode = "compare")
  
  

```  


South Korea
=======================================================================

```{r, include=FALSE}

df_southkorea <- coronavirus_b %>% 
  filter(country == "Korea") %>%
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = F)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  arrange(date) %>%
  ungroup()

coronavirus_southkorea <- coronavirus_b %>%
  filter (country == "Korea")

df_southkorea_valuebox<-df %>%
  filter (country == "Korea")

df_daily_southkorea  <- coronavirus_southkorea %>% 
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = TRUE)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  mutate_if(is.numeric, ~replace(., is.na(.),0)) %>%
  arrange(date) %>%
  ungroup() %>%
  mutate(active =  confirmed - death - recovered) %>%
  mutate(confirmed_cumulative = cumsum(confirmed),
         death_cumulative = cumsum(death),
         recovered_cumulative = cumsum(recovered),
         active_cumulative = cumsum(active))

```

Column
-------------------------------------

### 

```{r, figh.height = 10}

df_southkorea %>%
  datatable(rownames = FALSE)

```

### Confirmed Cases (daily)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_southkorea) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ confirmed,
                    type = "bar",
                    line = list(color = confirmed_color),
                    marker = list(color = confirmed_color)) %>%
  plotly::layout(yaxis = list(title = "Confirmed Cases"),
                 xaxis = list(title = ""))

```

Column 
-------------------------------------
    
### Recovered Cases (cumulative)
    

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_southkorea) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::layout(yaxis = list(title = "Recovered Cases (cumulative)"),
                 xaxis = list(title = ""))

```  
   
### Death Cases (cumulative)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_southkorea) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::layout(yaxis = list(title = "Death Cases (cumulative)"),
                 xaxis = list(title = ""))


``` 
   
Column 
-------------------------------------
   
### confirmed {.value-box}

```{r}

valueBox(value = paste(format(sum(df_southkorea_valuebox$confirmed), big.mark = ","), "", sep = " "), 
         caption = "Confirmed Cases", 
         color = confirmed_color)
```


### active {.value-box}

```{r}

valueBox(value = paste(format(sum(df_southkorea_valuebox$unrecovered), big.mark = ","), "", sep = " "), 
         caption = "Active Cases",  
         color = active_color)
```

### recovered {.value-box}

```{r}

valueBox(value = paste(format(sum(df_southkorea_valuebox$recovered), big.mark = ","), "", sep = " "), 
         caption = "Recovered Cases", 
         color = recovered_color)
```

### death {.value-box}

```{r}

valueBox(value = paste(format(sum(df_southkorea_valuebox$death), big.mark = ","), "", sep = " "),
         caption = "Death Cases", 
         color = death_color)

```
  
  
South Korea (b)
=======================================================================

### Active, recovered and death cases over time (cumulative cases)

```{r}

plotly::plot_ly(data = df_daily_southkorea) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ active_cumulative,
                    type = "bar",
                    name = "Active",
                    line = list(color = active_color),
                    marker = list(color = active_color)) %>%
  plotly::layout(barmode = 'stack',
                 yaxis = list(title = "Total Cases"),
                 xaxis = list(title = ""),
                 hovermode = "compare")
  
  

```  
  

Iran
=======================================================================

```{r, include=FALSE}

df_Iran <- coronavirus_b %>% 
  filter(country == "Iran") %>%
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = F)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  arrange(date) %>%
  ungroup()

coronavirus_Iran <- coronavirus_b %>%
  filter (country == "Iran")

df_Iran_valuebox<-df %>%
  filter (country == "Iran")

df_daily_Iran  <- coronavirus_Iran %>% 
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = TRUE)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  mutate_if(is.numeric, ~replace(., is.na(.),0)) %>%
  arrange(date) %>%
  ungroup() %>%
  mutate(active =  confirmed - death - recovered) %>%
  mutate(confirmed_cumulative = cumsum(confirmed),
         death_cumulative = cumsum(death),
         recovered_cumulative = cumsum(recovered),
         active_cumulative = cumsum(active))

```

Column
-------------------------------------

### 

```{r, figh.height = 10}

df_Iran %>%
  datatable(rownames = FALSE)

```

### Confirmed Cases (daily)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_Iran) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ confirmed,
                    type = "bar",
                    line = list(color = confirmed_color),
                    marker = list(color = confirmed_color)) %>%
  plotly::layout(yaxis = list(title = "Confirmed Cases"),
                 xaxis = list(title = ""))

```

Column 
-------------------------------------
    
### Recovered Cases (cumulative)
    

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_Iran) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::layout(yaxis = list(title = "Recovered Cases (cumulative)"),
                 xaxis = list(title = ""))

```  
   
### Death Cases (cumulative)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_Iran) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::layout(yaxis = list(title = "Death Cases (cumulative)"),
                 xaxis = list(title = ""))


``` 
   
Column 
-------------------------------------
   
### confirmed {.value-box}

```{r}

valueBox(value = paste(format(sum(df_Iran_valuebox$confirmed), big.mark = ","), "", sep = " "), 
         caption = "Confirmed Cases", 
         color = confirmed_color)
```


### active {.value-box}

```{r}

valueBox(value = paste(format(sum(df_Iran_valuebox$unrecovered), big.mark = ","), "", sep = " "), 
         caption = "Active Cases",  
         color = active_color)
```

### recovered {.value-box}

```{r}

valueBox(value = paste(format(sum(df_Iran_valuebox$recovered), big.mark = ","), "", sep = " "), 
         caption = "Recovered Cases", 
         color = recovered_color)
```

### death {.value-box}

```{r}

valueBox(value = paste(format(sum(df_Iran_valuebox$death), big.mark = ","), "", sep = " "),
         caption = "Death Cases", 
         color = death_color)

```
        
Iran (b)
=======================================================================

### Active, recovered and death cases over time (cumulative cases)

```{r}

plotly::plot_ly(data = df_daily_Iran) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ active_cumulative,
                    type = "bar",
                    name = "Active",
                    line = list(color = active_color),
                    marker = list(color = active_color)) %>%
  plotly::layout(barmode = 'stack',
                 yaxis = list(title = "Total Cases"),
                 xaxis = list(title = ""),
                 hovermode = "compare")
  
  

```  


United Kingdom
=======================================================================

```{r, include=FALSE}

df_uk <- coronavirus_b %>% 
  filter(country == "United Kingdom") %>%
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = F)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  arrange(date) %>%
  ungroup()

coronavirus_uk <- coronavirus_b %>%
  filter (country == "United Kingdom")

df_uk_valuebox<-df %>%
  filter (country == "United Kingdom")

df_daily_uk  <- coronavirus_uk %>% 
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = TRUE)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  mutate_if(is.numeric, ~replace(., is.na(.),0)) %>%
  arrange(date) %>%
  ungroup() %>%
  mutate(active =  confirmed - death - recovered) %>%
  mutate(confirmed_cumulative = cumsum(confirmed),
         death_cumulative = cumsum(death),
         recovered_cumulative = cumsum(recovered),
         active_cumulative = cumsum(active))

```

Column
-------------------------------------

### 

```{r, figh.height = 10}

df_uk %>%
  datatable(rownames = FALSE)

```

### Confirmed Cases (daily)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_uk) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ confirmed,
                    type = "bar",
                    line = list(color = confirmed_color),
                    marker = list(color = confirmed_color)) %>%
  plotly::layout(yaxis = list(title = "Confirmed Cases"),
                 xaxis = list(title = ""))

```

Column 
-------------------------------------
    
### Recovered Cases (cumulative)
    

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_uk) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::layout(yaxis = list(title = "Recovered Cases (cumulative)"),
                 xaxis = list(title = ""))

```  
   
### Death Cases (cumulative)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_uk) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::layout(yaxis = list(title = "Death Cases (cumulative)"),
                 xaxis = list(title = ""))


``` 
   
Column 
-------------------------------------
   
### confirmed {.value-box}

```{r}

valueBox(value = paste(format(sum(df_uk_valuebox$confirmed), big.mark = ","), "", sep = " "), 
         caption = "Confirmed Cases", 
         color = confirmed_color)
```


### active {.value-box}

```{r}

valueBox(value = paste(format(sum(df_uk_valuebox$unrecovered), big.mark = ","), "", sep = " "), 
         caption = "Active Cases",  
         color = active_color)
```

### recovered {.value-box}

```{r}

valueBox(value = paste(format(sum(df_uk_valuebox$recovered), big.mark = ","), "", sep = " "), 
         caption = "Recovered Cases", 
         color = recovered_color)
```

### death {.value-box}

```{r}

valueBox(value = paste(format(sum(df_uk_valuebox$death), big.mark = ","), "", sep = " "),
         caption = "Death Cases", 
         color = death_color)

```      
   
   
United Kingdom (b)
=======================================================================

### Active, recovered and death cases over time (cumulative cases)

```{r}

plotly::plot_ly(data = df_daily_uk) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ active_cumulative,
                    type = "bar",
                    name = "Active",
                    line = list(color = active_color),
                    marker = list(color = active_color)) %>%
  plotly::layout(barmode = 'stack',
                 yaxis = list(title = "Total Cases"),
                 xaxis = list(title = ""),
                 hovermode = "compare")
  
  

```  


United States
=======================================================================

```{r, include=FALSE}

df_us <- coronavirus_b %>% 
  filter(country == "US") %>%
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = F)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  arrange(date) %>%
  ungroup()

coronavirus_us <- coronavirus_b %>%
  filter (country == "US")

df_us_valuebox<-df %>%
  filter (country == "US")

df_daily_us  <- coronavirus_us %>% 
  group_by(date, type) %>%
  summarise(total = sum(cases, na.rm = TRUE)) %>%
  pivot_wider(names_from = type,
              values_from = total) %>%
  mutate_if(is.numeric, ~replace(., is.na(.),0)) %>%
  arrange(date) %>%
  ungroup() %>%
  mutate(active =  confirmed - death - recovered) %>%
  mutate(confirmed_cumulative = cumsum(confirmed),
         death_cumulative = cumsum(death),
         recovered_cumulative = cumsum(recovered),
         active_cumulative = cumsum(active))

```

Column
-------------------------------------

### 

```{r, figh.height = 10}

df_us %>%
  datatable(rownames = FALSE)

```

### Confirmed Cases (daily)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_us) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ confirmed,
                    type = "bar",
                    line = list(color = confirmed_color),
                    marker = list(color = confirmed_color)) %>%
  plotly::layout(yaxis = list(title = "Confirmed Cases"),
                 xaxis = list(title = ""))

```

Column 
-------------------------------------
    
### Recovered Cases (cumulative)
    

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_us) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::layout(yaxis = list(title = "Recovered Cases (cumulative)"),
                 xaxis = list(title = ""))

```  
   
### Death Cases (cumulative)

```{r, fig.width=10, fig.height=10}

plotly::plot_ly(data = df_daily_us) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::layout(yaxis = list(title = "Death Cases (cumulative)"),
                 xaxis = list(title = ""))


``` 
   
Column 
-------------------------------------
   
### confirmed {.value-box}

```{r}

valueBox(value = paste(format(sum(df_us_valuebox$confirmed), big.mark = ","), "", sep = " "), 
         caption = "Confirmed Cases", 
         color = confirmed_color)
```


### active {.value-box}

```{r}

valueBox(value = paste(format(sum(df_us_valuebox$unrecovered), big.mark = ","), "", sep = " "), 
         caption = "Active Cases",  
         color = active_color)
```

### recovered {.value-box}

```{r}

valueBox(value = paste(format(sum(df_us_valuebox$recovered), big.mark = ","), "", sep = " "), 
         caption = "Recovered Cases", 
         color = recovered_color)
```

### death {.value-box}

```{r}

valueBox(value = paste(format(sum(df_us_valuebox$death), big.mark = ","), "", sep = " "),
         caption = "Death Cases", 
         color = death_color)

```      
 
      
United States (b)
=======================================================================

### Active, recovered and death cases over time (cumulative cases)

```{r}

plotly::plot_ly(data = df_daily_us) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ death_cumulative,
                    type = "bar",
                    name = "Death",
                    line = list(color = death_color),
                    marker = list(color = death_color))%>%
  plotly::add_trace(x = ~ date,
                    y = ~ recovered_cumulative,
                    type = "bar",
                    name = "Recovered",
                    line = list(color = recovered_color),
                    marker = list(color = recovered_color)) %>%
  plotly::add_trace(x = ~ date,
                    y = ~ active_cumulative,
                    type = "bar",
                    name = "Active",
                    line = list(color = active_color),
                    marker = list(color = active_color)) %>%
  plotly::layout(barmode = 'stack',
                 yaxis = list(title = "Total Cases"),
                 xaxis = list(title = ""),
                 hovermode = "compare")
  
  

```