Summary

Row

confirmed

97

confirmed (Kenya)

490

confirmed (Tanzania)

480

confirmed (Rwanda)

261

confirmed (Burundi)

15

Row

death

0 (0%)

death

24 (4.9%)

death

16 (3.3%)

death

0 (0%)

death

1 (6.7%)

Row

Daily cumulative cases by type (Uganda only)

Comparison

Column

Daily new confirmed cases

Cases distribution by type

Trajectory

Row

Trajectory Plot - East African Countries

Map

World map of cases (use + and - icons to zoom in/out)

About

The Coronavirus Dashboard: the case of East Africa

This Coronavirus dashboard: the case of East Africa started out with a focus on Ugana but has not been updated to include and compare with surrounding East African countries. It provides an overview of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic for the East african countries of Uganda, Kenya, Tanzania, Rwanda and Burundi.

This dashboard is built with R using the R Markdown framework and was adapted from this dashboard by Rami Krispin.

Code

The code behind this dashboard is available on GitHub.

Data

The input data for this dashboard is the dataset available from the {coronavirus} R package. Make sure to download the development version of the package to have the latest data:

install.packages("devtools")
devtools::install_github("RamiKrispin/coronavirus")

The data and dashboard are refreshed on a daily basis.

The raw data is pulled from the Johns Hopkins University Center for Systems Science and Engineering (JHU CCSE) Coronavirus repository.

Contact

For any question or feedback, you can contact me. More information about this dashboard can be found in this article.

Update

The data is as of Monday May 04, 2020 and the dashboard has been updated on Wednesday May 06, 2020.

---
title: "Coronavirus in East Africa"
author: "Drew Ddembe"
date: "`r Sys.Date()`" 
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    # social: ["facebook", "twitter", "linkedin"]
    source_code: embed
    vertical_layout: fill
---

```{r setup, include=FALSE}
#------------------ Packages ------------------
library(flexdashboard)
# install.packages("devtools")
devtools::install_github("RamiKrispin/coronavirus", force = TRUE)
library(coronavirus)
data(coronavirus)
#update_datasets()
# View(coronavirus)
# max(coronavirus$date)

`%>%` <- magrittr::`%>%`
#------------------ Parameters ------------------
# Set colors
# https://www.w3.org/TR/css-color-3/#svg-color
confirmed_color <- "purple"
active_color <- "#1f77b4"
recovered_color <- "forestgreen"
death_color <- "red"
#------------------ Data ------------------
df_kenya <- coronavirus %>%
   #dplyr::filter(date == max(date)) %>%
   dplyr::filter(Country.Region == "Kenya") %>%
   dplyr::group_by(Country.Region, type) %>%
   dplyr::summarise(total = sum(cases)) %>%
   tidyr::pivot_wider(
     names_from = type,
     values_from = total
   )
df_tanzania <- coronavirus %>%
   #dplyr::filter(date == max(date)) %>%
   dplyr::filter(Country.Region == "Tanzania") %>%
   dplyr::group_by(Country.Region, type) %>%
   dplyr::summarise(total = sum(cases)) %>%
   tidyr::pivot_wider(
     names_from = type,
     values_from = total
   )
df_rwanda <- coronavirus %>%
   #dplyr::filter(date == max(date)) %>%
   dplyr::filter(Country.Region == "Rwanda") %>%
   dplyr::group_by(Country.Region, type) %>%
   dplyr::summarise(total = sum(cases)) %>%
   tidyr::pivot_wider(
     names_from = type,
     values_from = total
   )
df_burundi <- coronavirus %>%
   #dplyr::filter(date == max(date)) %>%
   dplyr::filter(Country.Region == "Burundi") %>%
   dplyr::group_by(Country.Region, type) %>%
   dplyr::summarise(total = sum(cases)) %>%
   tidyr::pivot_wider(
     names_from = type,
     values_from = total
   )

df <- coronavirus %>%
  #dplyr::filter(date == max(date)) %>%
  dplyr::filter(Country.Region == "Uganda") %>%
  dplyr::group_by(Country.Region, type) %>%
  dplyr::summarise(total = sum(cases)) %>%
  tidyr::pivot_wider(
    names_from = type,
    values_from = total
  ) %>%
  # dplyr::mutate(unrecovered = confirmed - ifelse(is.na(recovered), 0, recovered) - ifelse(is.na(death), 0, death)) %>%
  dplyr::mutate(unrecovered = confirmed - ifelse(is.na(death), 0, death)) %>%
  dplyr::arrange(-confirmed) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(country = dplyr::if_else(Country.Region == "United Arab Emirates", "UAE", Country.Region)) %>%
  dplyr::mutate(country = dplyr::if_else(country == "Mainland China", "China", country)) %>%
  dplyr::mutate(country = dplyr::if_else(country == "North Macedonia", "N.Macedonia", country)) %>%
  dplyr::mutate(country = trimws(country)) %>%
  dplyr::mutate(country = factor(country, levels = country))

df_daily <- coronavirus %>%
  dplyr::filter(Country.Region == "Uganda") %>%
  dplyr::group_by(date, type) %>%
  dplyr::summarise(total = sum(cases, na.rm = TRUE)) %>%
  tidyr::pivot_wider(
    names_from = type,
    values_from = total
  ) %>%
  dplyr::arrange(date) %>%
  dplyr::ungroup() %>%
  #dplyr::mutate(active = confirmed - death - recovered) %>%
  dplyr::mutate(active = confirmed - death) %>%
  dplyr::mutate(
    confirmed_cum = cumsum(confirmed),
    death_cum = cumsum(death),
    # recovered_cum = cumsum(recovered),
    active_cum = cumsum(active)
  )


#df1 <- coronavirus %>% dplyr::filter(date == max(date))


#------------trajectory plot data prep------------

df_ug <- coronavirus %>% dplyr::filter(type == "confirmed", Country.Region == "Uganda") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(ug = cumsum(cases)) %>%
  dplyr::filter(ug > 1)  %>%
  dplyr::select(-cases, -date)
df_ug$index <- 1:nrow(df_ug)

df_tz <- coronavirus %>% dplyr::filter(type == "confirmed", Country.Region == "Tanzania") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(tz = cumsum(cases)) %>%
  dplyr::filter(tz > 1)  %>%
  dplyr::select(-cases, -date)
df_tz$index <- 1:nrow(df_tz)

df_ke <- coronavirus %>% dplyr::filter(type == "confirmed", Country.Region == "Kenya") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(ke = cumsum(cases)) %>%
  dplyr::filter(ke > 1)  %>%
  dplyr::select(-cases, -date)
df_ke$index <- 1:nrow(df_ke)

df_rw <- coronavirus %>% dplyr::filter(type == "confirmed", Country.Region == "Rwanda") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(rw = cumsum(cases)) %>%
  dplyr::filter(rw > 1)  %>%
  dplyr::select(-cases, -date)
df_rw$index <- 1:nrow(df_rw)

df_bu <- coronavirus %>% dplyr::filter(type == "confirmed", Country.Region == "Burundi") %>%
  dplyr::group_by(date) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::ungroup() %>%
  dplyr::arrange(date) %>%
  dplyr::mutate(bu = cumsum(cases)) %>%
  dplyr::filter(bu > 1)  %>%
  dplyr::select(-cases, -date)
df_bu$index <- 1:nrow(df_bu)

df_trajectory <- df_ug %>% 
  dplyr::left_join(df_ke, by = "index") %>%
  dplyr::left_join(df_tz, by = "index") %>%
  dplyr::left_join(df_rw, by = "index") %>%
  dplyr::left_join(df_bu, by = "index")

```

Summary
=======================================================================

Row {data-width=160}
-----------------------------------------------------------------------

### confirmed {.value-box}

```{r}

valueBox(
  value = paste(format(sum(df$confirmed), big.mark = ","), "", sep = " "),
  caption = "Total confirmed cases (Uganda)",
  icon = "fas fa-user-md",
  color = confirmed_color
)
```



### confirmed (Kenya) {.value-box}

```{r}

valueBox(
  value = paste(format(sum(df_kenya$confirmed), big.mark = ","), "", sep = " "),
  caption = "Total confirmed cases (Kenya)",
  icon = "fas fa-user-md",
  color = confirmed_color
)
```

### confirmed (Tanzania) {.value-box}

```{r}

valueBox(
  value = paste(format(sum(df_tanzania$confirmed), big.mark = ","), "", sep = " "),
  caption = "Total confirmed cases (Tanzania)",
  icon = "fas fa-user-md",
  color = confirmed_color
)
```

### confirmed (Rwanda) {.value-box}

```{r}

valueBox(
  value = paste(format(sum(df_rwanda$confirmed), big.mark = ","), "", sep = " "),
  caption = "Total confirmed cases (Rwanda)",
  icon = "fas fa-user-md",
  color = confirmed_color
)
```

### confirmed (Burundi) {.value-box}

```{r}

valueBox(
  value = paste(format(sum(df_burundi$confirmed), big.mark = ","), "", sep = " "),
  caption = "Total confirmed cases (Burundi)",
  icon = "fas fa-user-md",
  color = confirmed_color
)
```

Row {data-width=160}
-----------------------------------------------------------------------

### 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 Uganda (death rate)",
  icon = "fas fa-heart-broken",
  color = death_color
)
```

### death {.value-box}

```{r}

valueBox(
  value = paste(format(sum(df_kenya$death, na.rm = TRUE), big.mark = ","), " (",
    round(100 * sum(df_kenya$death, na.rm = TRUE) / sum(df_kenya$confirmed), 1),
    "%)",
    sep = ""
  ),
  caption = "Death cases Kenya (death rate)",
  icon = "fas fa-heart-broken",
  color = death_color
)
```

### death {.value-box}

```{r}

valueBox(
  value = paste(format(sum(df_tanzania$death, na.rm = TRUE), big.mark = ","), " (",
    round(100 * sum(df_tanzania$death, na.rm = TRUE) / sum(df_tanzania$confirmed), 1),
    "%)",
    sep = ""
  ),
  caption = "Death cases Tanzania (death rate)",
  icon = "fas fa-heart-broken",
  color = death_color
)
```

### death {.value-box}

```{r}

valueBox(
  value = paste(format(sum(df_rwanda$death, na.rm = TRUE), big.mark = ","), " (",
    round(100 * sum(df_rwanda$death, na.rm = TRUE) / sum(df_rwanda$confirmed), 1),
    "%)",
    sep = ""
  ),
  caption = "Death cases Rwanda (death rate)",
  icon = "fas fa-heart-broken",
  color = death_color
)
```

### death {.value-box}

```{r}

valueBox(
  value = paste(format(sum(df_burundi$death, na.rm = TRUE), big.mark = ","), " (",
    round(100 * sum(df_burundi$death, na.rm = TRUE) / sum(df_burundi$confirmed), 1),
    "%)",
    sep = ""
  ),
  caption = "Death cases Burundi (death rate)",
  icon = "fas fa-heart-broken",
  color = death_color
)
```


Row
-----------------------------------------------------------------------

### **Daily cumulative cases by type** (Uganda only)
    
```{r}
plotly::plot_ly(data = df_daily) %>%
  plotly::add_trace(
    x = ~date,
    # y = ~active_cum,
    y = ~confirmed_cum,
    type = "scatter",
    mode = "lines+markers",
    # name = "Active",
    name = "Confirmed",
    line = list(color = active_color),
    marker = list(color = active_color)
  ) %>%
  plotly::add_trace(
    x = ~date,
    y = ~death_cum,
    type = "scatter",
    mode = "lines+markers",
    name = "Death",
    line = list(color = death_color),
    marker = list(color = death_color)
  ) %>%
  plotly::add_annotations(
    x = as.Date("2020-03-30"),
    y = 35,
    text = paste(
      "Lockdown"
    ),
    xref = "x",
    yref = "y",
    arrowhead = 5,
    arrowhead = 3,
    arrowsize = 1,
    showarrow = TRUE,
    ax = -10,
    ay = -90
  ) %>%
  plotly::layout(
    title = "",
    yaxis = list(title = "Cumulative number of cases"),
    xaxis = list(title = "Date"),
    legend = list(x = 0.1, y = 0.9),
    hovermode = "compare"
  )
```


Comparison
=======================================================================


Column {data-width=400}
-------------------------------------


### **Daily new confirmed cases**
    
```{r}
daily_confirmed <- coronavirus %>%
  dplyr::filter(type == "confirmed") %>%
  dplyr::filter(date >= "2020-02-29") %>%
  dplyr::mutate(country = Country.Region) %>%
  dplyr::group_by(date, country) %>%
  dplyr::summarise(total = sum(cases)) %>%
  dplyr::ungroup() %>%
  tidyr::pivot_wider(names_from = country, values_from = total)

#----------------------------------------
# Plotting the data

daily_confirmed %>%
  plotly::plot_ly() %>%
  plotly::add_trace(
    x = ~date,
    y = ~Uganda,
    type = "scatter",
    mode = "lines+markers",
    name = "Uganda"
  ) %>%
  plotly::add_trace(
    x = ~date,
    y = ~Tanzania,
    type = "scatter",
    mode = "lines+markers",
    name = "Tanzania"
  ) %>%
  plotly::add_trace(
    x = ~date,
    y = ~Kenya,
    type = "scatter",
    mode = "lines+markers",
    name = "Kenya"
  ) %>%
  plotly::add_trace(
    x = ~date,
    y = ~Rwanda,
    type = "scatter",
    mode = "lines+markers",
    name = "Rwanda"
  ) %>%
  plotly::add_trace(
    x = ~date,
    y = ~Burundi,
    type = "scatter",
    mode = "lines+markers",
    name = "Burundi"
  ) %>%
  plotly::layout(
    title = "",
    legend = list(x = 0.1, y = 0.9),
    yaxis = list(title = "Number of new confirmed cases"),
    xaxis = list(title = "Date"),
    # paper_bgcolor = "black",
    # plot_bgcolor = "black",
    # font = list(color = 'white'),
    hovermode = "compare",
    margin = list(
      # l = 60,
      # r = 40,
      b = 10,
      t = 10,
      pad = 2
    )
  )
```
 
### **Cases distribution by type**

```{r daily_summary}
df_EA <- coronavirus %>%
  # dplyr::filter(date == max(date)) %>%
  dplyr::filter(Country.Region == "Uganda" |
    Country.Region == "Tanzania" |
    Country.Region == "Kenya" |
    Country.Region == "Rwanda" |
    Country.Region == "Burundi") %>%
  dplyr::group_by(Country.Region, type) %>%
  dplyr::summarise(total = sum(cases)) %>%
  tidyr::pivot_wider(
    names_from = type,
    values_from = total
  ) %>%
  # dplyr::mutate(unrecovered = confirmed - ifelse(is.na(recovered), 0, recovered) - ifelse(is.na(death), 0, death)) %>%
  dplyr::mutate(unrecovered = confirmed - ifelse(is.na(death), 0, death)) %>%
  dplyr::arrange(confirmed) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(country = dplyr::if_else(Country.Region == "United Arab Emirates", "UAE", Country.Region)) %>%
  dplyr::mutate(country = dplyr::if_else(country == "Mainland China", "China", country)) %>%
  dplyr::mutate(country = dplyr::if_else(country == "North Macedonia", "N.Macedonia", country)) %>%
  dplyr::mutate(country = trimws(country)) %>%
  dplyr::mutate(country = factor(country, levels = country))

plotly::plot_ly(
  data = df_EA,
  x = ~country,
  # y = ~unrecovered,
  y = ~ confirmed,
  # text =  ~ confirmed,
  # textposition = 'auto',
  type = "bar",
  name = "Confirmed",
  marker = list(color = active_color)
) %>%
  plotly::add_trace(
    y = ~death,
    # text =  ~ death,
    # textposition = 'auto',
    name = "Death",
    marker = list(color = death_color)
  ) %>%
  plotly::layout(
    barmode = "stack",
    yaxis = list(title = "Total cases"),
    xaxis = list(title = ""),
    hovermode = "compare",
    margin = list(
      # l = 60,
      # r = 40,
      b = 10,
      t = 10,
      pad = 2
    )
  )
```

Trajectory
=======================================================================

Row {data-width=800}
-----------------------------------------------------------------------

### Trajectory Plot - East African Countries 

```{r}
plotly::plot_ly(data = df_trajectory) %>%
  plotly::add_lines(x = ~ index,
                    y = ~ ug,
                    name = "Uganda",  line = list(width = 2)) %>%
  plotly::add_lines(x = ~ index,
                    y = ~ ke,
                    line = list(color = "red", width = 2),
                    name = "Kenya") %>%
  plotly::add_lines(x = ~ index,
                    y = ~ tz,
                    name = "Tanzania",  line = list(width = 2)) %>%
    plotly::add_lines(x = ~ index,
                    y = ~ rw,
                    name = "Rwanda",  line = list(width = 2)) %>%
      plotly::add_lines(x = ~ index,
                    y = ~ bu,
                    name = "Burundi",  line = list(width = 2)) %>%
  #plotly::layout(yaxis = list(title = "Cumulative Positive Cases",type = 'scatter', mode = 'lines'),
  plotly::layout(yaxis = list(title = "Cumulative Positive Cases",type = 'log'),
                 xaxis = list(title = "Days since the total positive cases surpass 1"),
                 legend = list(x = 0.7, y = 0.3),
                 hovermode = "compare")
```

  

Map
=======================================================================

### **World map of cases** (*use + and - icons to zoom in/out*)

```{r}
# map tab added by Art Steinmetz
library(leaflet)
library(leafpop)
library(purrr)
cv_data_for_plot <- coronavirus %>%
  # dplyr::filter(Country.Region == "Uganda") %>%
  dplyr::filter(cases > 0) %>%
  dplyr::group_by(Country.Region, Province.State, Lat, Long, type) %>%
  dplyr::summarise(cases = sum(cases)) %>%
  dplyr::mutate(log_cases = 2 * log(cases)) %>%
  dplyr::ungroup()
cv_data_for_plot.split <- cv_data_for_plot %>% split(cv_data_for_plot$type)
pal <- colorFactor(c("orange", "red", "green"), domain = c("confirmed", "death", "recovered"))
map_object <- leaflet() %>% addProviderTiles(providers$Stamen.Toner)
names(cv_data_for_plot.split) %>%
  purrr::walk(function(df) {
    map_object <<- map_object %>%
      addCircleMarkers(
        data = cv_data_for_plot.split[[df]],
        lng = ~Long, lat = ~Lat,
        #                 label=~as.character(cases),
        color = ~ pal(type),
        stroke = FALSE,
        fillOpacity = 0.8,
        radius = ~log_cases,
        popup = leafpop::popupTable(cv_data_for_plot.split[[df]],
          feature.id = FALSE,
          row.numbers = FALSE,
          zcol = c("type", "cases", "Country.Region", "Province.State")
        ),
        group = df,
        #                 clusterOptions = markerClusterOptions(removeOutsideVisibleBounds = F),
        labelOptions = labelOptions(
          noHide = F,
          direction = "auto"
        )
      )
  })

map_object %>%
  addLayersControl(
    overlayGroups = names(cv_data_for_plot.split),
    options = layersControlOptions(collapsed = FALSE)
  )
```





About
=======================================================================

**The Coronavirus Dashboard: the case of East Africa**

This Coronavirus dashboard: the case of East Africa started out with a focus on Ugana but has not been updated to include and compare with surrounding East African countries. It provides an overview of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic for the East african countries of Uganda, Kenya, Tanzania, Rwanda and Burundi.

This dashboard is built with R using the R Markdown framework and was adapted from this [dashboard](https://ramikrispin.github.io/coronavirus_dashboard/){target="_blank"} by Rami Krispin.

**Code**

The code behind this dashboard is available on [GitHub](https://github.com/AntoineSoetewey/coronavirus_dashboard){target="_blank"}.

**Data**

The input data for this dashboard is the dataset available from the [`{coronavirus}`](https://github.com/RamiKrispin/coronavirus){target="_blank"} R package. Make sure to download the development version of the package to have the latest data:

```
install.packages("devtools")
devtools::install_github("RamiKrispin/coronavirus")
```

The data and dashboard are refreshed on a daily basis.

The raw data is pulled from the Johns Hopkins University Center for Systems Science and Engineering (JHU CCSE) Coronavirus [repository](https://github.com/RamiKrispin/coronavirus-csv){target="_blank"}.

**Contact**

For any question or feedback, you can [contact me](www.facebook.com/drew.ddembe). More information about this dashboard can be found in this [article](https://www.statsandr.com/blog/how-to-create-a-simple-coronavirus-dashboard-specific-to-your-country-in-r/).

**Update**

The data is as of `r format(max(coronavirus$date), "%A %B %d, %Y")` and the dashboard has been updated on `r format(Sys.time(), "%A %B %d, %Y")`.