Summary

Row

confirmed

1,112,643

death

8,530 (0.8%)

recovered

1,104,046

active

67 (0%)

### DOMINICAN REPUBLIC

confirmed

660,790

death

4,384 (0.7%)

recovered

656,267

active

139 (0%)

### JAMAICA

confirmed

154,416

death

3,514 (2.3%)

recovered

101,288

active

49,614 (32.1%)

### HAITI

confirmed

34,202

death

860 (2.5%)

recovered

33,120

active

222 (0.6%)

Comparison

Column

Daily New Confirmed Cases (Caribbean)

Cases distribution by type

Deaths Comparison

Column

Deaths distribution

Forecasts

14 Days Forecasts for HAITI

# A tsibble: 42 x 5 [1D]
# Key:       .model [3]
   .model date          New_Cases  .mean                    `80%`
   <chr>  <date>           <dist>  <dbl>                   <hilo>
 1 ets    2022-02-23  N(42, 4370)  41.8  [-42.94460, 126.49972]80
 2 ets    2022-02-24  N(40, 4433)  39.9  [-45.38101, 125.26779]80
 3 ets    2022-02-25  N(38, 4495)  38.2  [-47.74857, 124.09826]80
 4 ets    2022-02-26   N(8, 4558)   7.96 [-78.55733,  94.48122]80
 5 ets    2022-02-27  N(26, 4620)  26.5  [-60.61751, 113.60658]80
 6 ets    2022-02-28 N(101, 4683) 101.   [ 13.39800, 188.80158]80
 7 ets    2022-03-01  N(43, 4746)  43.0  [-45.30108, 131.27606]80
 8 ets    2022-03-02  N(42, 4866)  42.1  [-47.28510, 131.51219]80
 9 ets    2022-03-03  N(40, 4929)  40.3  [-49.69690, 130.25565]80
10 ets    2022-03-04  N(39, 4992)  38.5  [-52.04034, 129.06200]80
# ℹ 32 more rows

# A tsibble: 3 x 5 [1D]
# Key:       .model [3]
  .model date         New_Cases .mean                    `80%`
  <chr>  <date>          <dist> <dbl>                   <hilo>
1 ets    2022-02-23 N(42, 4370)  41.8 [-42.94460, 126.49972]80
2 arima  2022-02-23 N(17, 4217)  16.7 [-66.55728,  99.89207]80
3 mixed  2022-02-23 N(29, 4194)  29.2 [-53.76742, 112.21238]80

CLUSTERS

CLUSTER ANALYSIS OF CARIBBEAN CORONAVIRUS DEATHS /MILLION POPULATION

About

The Coronavirus Dashboard: the case of Haiti & Caribbean neighbours Cuba, Jamaica and the Dominican Republic

This Coronavirus dashboard: the case of Haiti compared to Caribbean neighbours Cuba, Jamaica and the Dominican Republic provides an overview of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic for Haiti and the Caribbean. This dashboard is built with R using the R Markdown framework and was adapted from this dashboard by Rami Krispin. Our ambition is to refresh the data daily, however we rely on the \[`{coronavirus}`\] data being updated by Rami Krispin. The 14 Days Forecasts section will alternate between Caribbean countries every 4 Days. The Forecasts assume historical patterns that have been modelled will continue into the forecast period and does not take into account newly introduced measures to combat the pandemic. Although point forecasts are presented, for greater certainty refer to the uncertainty around the estimate as per the shaded area on the graphic. Because of space we present only a single model forecasts (ets), which often represents the worse case scenario.

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 raw data is pulled from the Johns Hopkins University Center for Systems Science and Engineering (JHU CCSE) Coronavirus repository.

Information

More information about this dashboard (and how to replicate it for your own country) can be found in this article.

Update

The data is as of Thursday March 09, 2023 and the dashboard has been updated on Friday November 17, 2023.


Go back to statsandr.com (blog) or antoinesoetewey.com (personal website).

---
title: "Haiti Dashboard: #HAITI Edition "
author: "Pat Stephenson"
date: "17/11/2023"
output: 


  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    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)
# View(coronavirus)
#max(coronavirus$date)
`%>%` <- magrittr::`%>%`
#------------------ Parameters ------------------
# Set colors
# https://www.w3.org/TR/css-color-3/#svg-color
confirmed_color <- "black"
active_color <- "#1f77b4"
recovered_color <- "forestgreen"
death_color <- "red"
#------------------ Data ------------------
df <- coronavirus %>%

  # dplyr::filter(date == max(date)) %>%
  dplyr::filter(country == "Cuba") %>%
  dplyr::group_by(country, type) %>%
  dplyr::summarise(total = sum(cases)) %>%
  tidyr::pivot_wider(
    names_from = type,
    values_from = total
  ) %>%
   #dplyr::mutate(unrecovered = confirmed - recovered - death ,if else(is.na(death), 0, death)) %>%
  dplyr::mutate(unrecovered = 67, ifelse(is.na(death), 0, death)) %>%  
 # dplyr::mutate(unrecovered = confirmed - ifelse(is.na(death), 0, death)) %>%
 dplyr::mutate( recovered = confirmed - death - 67) %>% 
    
    
    dplyr::arrange(-confirmed) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(country = dplyr::if_else(country == "United Arab Emirates", "UAE", country)) %>%
  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 == "Cuba") %>%
  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 =67) %>%
    dplyr::mutate( recovered = confirmed - death - active) %>%
  #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))
```

# Summary

## Row {data-width="400"}

### confirmed {.value-box}

```{r}
valueBox(
  value = paste(format(sum(df$confirmed), big.mark = ","), "", sep = " "),
  caption = "CUBA Total confirmed cases",
  icon = "fas fa-user-md",
  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 (% of total cases)", icon = "fas fa-ambulance", -->

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


```

### recovered {.value-box}

```{r}
valueBox(
  value = paste(format(sum(df$recovered), big.mark = ","), "", sep = " "),
  caption = "Total recovered",
  icon = "fas fa-user-md",
  color = recovered_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 (% of total cases)", 
     icon = "fas fa-ambulance",              
    color = active_color 
)
```

```{r}

#------------------ Data ------------------
df <- coronavirus %>%
  # dplyr::filter(date == max(date)) %>%
  dplyr::filter(country == "Dominican Republic") %>%
  dplyr::group_by(country, type) %>%
  dplyr::summarise(total = sum(cases)) %>%
  tidyr::pivot_wider(
    names_from = type,
    values_from = total
  ) %>%
   #dplyr::mutate(unrecovered = confirmed - recovered - death ,if else(is.na(death), 0, death)) %>%
  dplyr::mutate(unrecovered = 139	 , ifelse(is.na(death), 0, death)) %>%  
 # dplyr::mutate(unrecovered = confirmed - ifelse(is.na(death), 0, death)) %>%
 dplyr::mutate( recovered = confirmed - death - 139	) %>% 
    
    
    dplyr::arrange(-confirmed) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(country = dplyr::if_else(country == "United Arab Emirates", "UAE", country)) %>%
  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 == "Dominican Republic") %>%
  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 = 139	) %>%
    dplyr::mutate( recovered = confirmed - death - active) %>%
  #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))
```

------------------------------------------------------------------------

## ##\# **DOMINICAN REPUBLIC**

### confirmed {.value-box}

```{r}
valueBox(
  value = paste(format(sum(df$confirmed), big.mark = ","), "", sep = " "),
  caption = "DR Total confirmed cases",
  icon = "fas fa-user-md",
  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 (% of total cases)", icon = "fas fa-ambulance", -->

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


```

### recovered {.value-box}

```{r}
valueBox(
  value = paste(format(sum(df$recovered), big.mark = ","), "", sep = " "),
  caption = "Total recovered",
  icon = "fas fa-user-md",
  color = recovered_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 (% of total cases)", 
     icon = "fas fa-ambulance",              
    color = active_color 
)
```

```{r}

#------------------ Data ------------------
df <- coronavirus %>%
  # dplyr::filter(date == max(date)) %>%
  dplyr::filter(country == "Jamaica") %>%
  dplyr::group_by(country, type) %>%
  dplyr::summarise(total = sum(cases)) %>%
  tidyr::pivot_wider(
    names_from = type,
    values_from = total
  ) %>%
   #dplyr::mutate(unrecovered = confirmed - recovered - death ,if else(is.na(death), 0, death)) %>%
  dplyr::mutate(unrecovered = 49614 , ifelse(is.na(death), 0, death)) %>%  
 # dplyr::mutate(unrecovered = confirmed - ifelse(is.na(death), 0, death)) %>%
 dplyr::mutate( recovered = confirmed - death - 49614) %>% 
    
    
    dplyr::arrange(-confirmed) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(country = dplyr::if_else(country == "United Arab Emirates", "UAE", country)) %>%
  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 == "Jamaica") %>%
  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 = 49614) %>%
    dplyr::mutate( recovered = confirmed - death - active) %>%
  #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))
```

------------------------------------------------------------------------

## ##\# **JAMAICA**

### confirmed {.value-box}

```{r}
valueBox(
  value = paste(format(sum(df$confirmed), big.mark = ","), "", sep = " "),
  caption = "JAMAICA Total confirmed cases",
  icon = "fas fa-user-md",
  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 (% of total cases)", icon = "fas fa-ambulance", -->

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


```

### recovered {.value-box}

```{r}
valueBox(
  value = paste(format(sum(df$recovered), big.mark = ","), "", sep = " "),
  caption = "Total recovered",
  icon = "fas fa-user-md",
  color = recovered_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 (% of total cases)", 
     icon = "fas fa-ambulance",              
    color = active_color 
)
```

```{r}

#------------------ Data ------------------
df <- coronavirus %>%
  # dplyr::filter(date == max(date)) %>%
  dplyr::filter(country == "Haiti") %>%
  dplyr::group_by(country, type) %>%
  dplyr::summarise(total = sum(cases)) %>%
  tidyr::pivot_wider(
    names_from = type,
    values_from = total
  ) %>%
   #dplyr::mutate(unrecovered = confirmed - recovered - death ,if else(is.na(death), 0, death)) %>%
  dplyr::mutate(unrecovered = 222, ifelse(is.na(death), 0, death)) %>%  
 # dplyr::mutate(unrecovered = confirmed - ifelse(is.na(death), 0, death)) %>%
 dplyr::mutate( recovered = confirmed - death - 222) %>% 
    
    
    dplyr::arrange(-confirmed) %>%
  dplyr::ungroup() %>%
  dplyr::mutate(country = dplyr::if_else(country == "United Arab Emirates", "UAE", country)) %>%
  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 == "Haiti") %>%
  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 = 222) %>%
    dplyr::mutate( recovered = confirmed - death - active) %>%
  #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))
```

------------------------------------------------------------------------

## ##\# **HAITI**

### confirmed {.value-box}

```{r}
valueBox(
  value = paste(format(sum(df$confirmed), big.mark = ","), "", sep = " "),
  caption = "HAITI Total confirmed cases",
  icon = "fas fa-user-md",
  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 (% of total cases)", icon = "fas fa-ambulance", -->

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


```

### recovered {.value-box}

```{r}
valueBox(
  value = paste(format(sum(df$recovered), big.mark = ","), "", sep = " "),
  caption = "Total recovered",
  icon = "fas fa-user-md",
  color = recovered_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 (% of total cases)", 
     icon = "fas fa-ambulance",              
    color = active_color 
)
```

# Comparison

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

### **Daily New Confirmed Cases** (Caribbean)

```{r}
daily_confirmed <- coronavirus %>%
  dplyr::filter(type == "confirmed") %>%
  dplyr::filter(date >= "2020-02-29") %>%
  dplyr::mutate(country = country) %>%
  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 = ~Haiti,
    type = "scatter",
    mode = "lines+markers",
    name = "Haiti"
  ) %>%
  # plotly::add_trace(
  #   x = ~date,
  #   y = ~France,
  #   type = "scatter",
  #   mode = "lines+markers",
  #   name = "France"
  # ) %>%
  # plotly::add_trace(
  #   x = ~date,
  #   y = ~Spain,
  #   type = "scatter",
  #   mode = "lines+markers",
  #   name = "Spain"
  # ) %>%
  plotly::add_trace(
    x = ~date,
    y = ~ `Dominican Republic`,
    type = "scatter",
    mode = "lines+markers",
    name = " Dominican Republic "
) %>%
    plotly::add_trace(
        x = ~date,
        y = ~Jamaica,
        type = "scatter",
        mode = "lines+markers",
        name = " Jamaica "
    ) %>%
    plotly::add_trace(
        x = ~date,
        y = ~Cuba,
        type = "scatter",
        mode = "lines+markers",
        name = " Cuba "
    ) %>%
   
        plotly::layout(
        title = "  ",
        legend = list(x = 0.1, y = 0.9),
        yaxis = list(title = "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_EU <- coronavirus %>%
  # dplyr::filter(date == max(date)) %>%
  dplyr::filter(country == "Haiti" |
    country == "Dominican Republic" |
    country == "Jamaica" |
    country == "Cuba") %>%
  dplyr::group_by(country, 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 == "United Arab Emirates", "UAE", country)) %>%
  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 = dplyr::if_else(country == "Canada", "Canada", country)) %>%
     
  dplyr::mutate(country = trimws(country)) %>%
  dplyr::mutate(country = factor(country, levels = country))

plotly::plot_ly(
  data = df_EU,
  x = ~country,
  # y = ~unrecovered,
  y = ~ confirmed,
  # text =  ~ confirmed,
  # textposition = 'auto',
  type = "bar",
  name = "Total cases",
  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
    )
  )

```

# Deaths Comparison

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

### **Deaths distribution**

```{r deaths_summary}
df_EU <- coronavirus %>%
  # dplyr::filter(date == max(date)) %>%
  dplyr::filter(country == "Haiti" |
    country == "Dominican Republic" |
    country == "Jamaica" |
    country == "Cuba") %>%
  dplyr::group_by(country, 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 == "United Arab Emirates", "UAE", country)) %>%
  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 = dplyr::if_else(country == "Canada", "Canada", country)) %>%
  
  dplyr::mutate(country = trimws(country)) %>%
  dplyr::mutate(country = factor(country, levels = country))
plotly::plot_ly(
  data = df_EU,
  x = ~country,
  # y = ~unrecovered,
  y = ~ death,
  # text =  ~ confirmed,
  # textposition = 'auto',
  type = "bar",
  name = "Total deaths",
  marker = list(color = death_color)
) %>%
  
  plotly::layout(
    barmode = "stack",
    yaxis = list(title = "Total deaths"),
    xaxis = list(title = ""),
    hovermode = "compare",
    margin = list(
      # l = 60,
      # r = 40,
      b = 10,
      t = 10,
      pad = 2
    )
  )

```

# Forecasts

### **14 Days Forecasts for** HAITI

```{r Forecasts_summary}

#HAITI
library(visdat)
library(naniar)
library(simputation)
library(tidyverse)
library(tsibble)
library(lubridate)
library(fable)
library(tidyquant)


corona_Can<-readr::read_csv("00_data/coronatshaI_CL.csv") %>%
    
    as_tsibble(index=date)


corona_Can1 <- corona_Can %>% 
    mutate(New_Cases=New_Cases+ 1)%>%
    
    # Label if New_Cases is missing
    add_label_missings(New_Cases) %>%
    # Imputation - Linear Regression impute_lm or impute_rf
    mutate(New_Cases = as.double(New_Cases)) %>%
    #impute_rf(New_Cases ~ Country)
    #impute_median( New_Cases ~ Country)
    impute_lm( New_Cases ~ date)
view(corona_Can1)


corona_Can2 <- corona_Can1 %>% select(date, New_Cases ) %>%
    as_tsibble(index=date)


corona_dat<- corona_Can2 %>%
    model(
        
        ets= ETS(New_Cases ~ error("A") + trend("A") + season("A")),
        arima = ARIMA(New_Cases)
    )%>%
    mutate(mixed = (arima + ets) / 2)



fcats<- corona_dat %>%
    
    forecast(h = 14)

hilo(fcats, level = 80)

fcats %>%
    
    
    
    autoplot(corona_Can2, level = 80) +
    ggtitle("14 Days Forecasts for Haiti, Feb-23, 2022") +
    xlab("Date") + ylab("New Cases")+
    theme_tq()
# Filtering the tsibble for Forecasts and 95% CIs BY DATE


hilo(fcats, level = 80)%>%
    filter(date =="2022-02-23")








```

# CLUSTERS

### **CLUSTER ANALYSIS OF CARIBBEAN CORONAVIRUS DEATHS /MILLION POPULATION**

```{r,  echo=FALSE, message=FALSE, results='hide', fig.width=12}



# CLUSTER ANALYSIS OF DEATHS IN CARIBBEAN CORONAVIRUS TIME SERIES USING K-MEANS
library(tidyverse)
library(lubridate)

library(brotools)
library(tidyquant)
set.seed(123)

corona_Can <-readr::read_csv("00_data/coronatsCarib_D.csv")
corona_Can1 <- corona_Can %>%
    select(Country, date, C_Deaths)

corona_wide <- corona_Can1 %>%
    pivot_wider(names_from = date, values_from = C_Deaths)  %>%
    
    mutate_at(vars(-Country), as.numeric)

corona_wide
 
wss <- map_dbl(1:3, ~{kmeans(select(corona_wide, -Country), ., nstart=4,iter.max = 15 )$tot.withinss})
n_clust <- 1:3
elbow_df <- as.data.frame(cbind("n_clust" = n_clust, "wss" = wss))

clusters <- kmeans(select(corona_wide, -Country), centers = 3)
(centers <- rownames_to_column(as.data.frame(clusters$centers), "cluster"))

corona_wide <- corona_wide %>% 
    mutate(cluster = clusters$cluster)

corona_long <- corona_wide %>%
    pivot_longer(cols=c(-Country, -cluster), names_to = "date", values_to = "C_Deaths") 
corona_long  

centers_long <- centers %>%
    pivot_longer(cols = -cluster, names_to = "date", values_to = "C_Deaths")   
centers_long

ggplot() +
    geom_point(data = corona_long, aes(y = C_Deaths, x = date, group = Country), colour = "#FF3030") +
    facet_wrap(~cluster, nrow = 1) + 
    geom_point(data = centers_long, aes(y = C_Deaths, x = date, group = cluster), col = "#b58900", size = 1) +
    theme_tq() + 
    
    labs(title = "Covid-19 Cumulative Deaths/Million for Caribbean countries 31/01/2022", 
         caption = "The different time series have been clustered using k-means.
                 Cluster 1: Cuba & Jamaica \n Cluster 2:Dominican R.  \n Cluster 3:Haiti ") +
    theme(plot.caption = element_text(colour = "black"))


```

# About

**The Coronavirus Dashboard: the case of Haiti & Caribbean neighbours Cuba, Jamaica and the Dominican Republic**

This Coronavirus dashboard: the case of Haiti compared to Caribbean neighbours Cuba, Jamaica and the Dominican Republic provides an overview of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic for Haiti and the Caribbean. 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. Our ambition is to refresh the data daily, however we rely on the \[`{coronavirus}`\] data being updated by Rami Krispin. The 14 Days Forecasts section will alternate between Caribbean countries every 4 Days. The Forecasts assume historical patterns that have been modelled will continue into the forecast period and does not take into account newly introduced measures to combat the pandemic. Although point forecasts are presented, for greater certainty refer to the uncertainty around the estimate as per the shaded area on the graphic. Because of space we present only a single model forecasts (ets), which often represents the worse case scenario.

**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 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"}.

**Information**

More information about this dashboard (and how to replicate it for your own country) can be found in this [article](https://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")`.

<br>

*Go back to [statsandr.com](https://statsandr.com/) (blog) or [antoinesoetewey.com](https://www.antoinesoetewey.com/) (personal website)*.