Calculate Shannon Index for a Series

Usage,
calculate_shannon(incidence)

Arguments

incidence

numeric, the case incidence

Value

double, the intensity of epidemic calculated via Shannon index

Examples

dat <- nccovid::get_covid_state(c("Guilford", "Forsyth", "Mecklenburg", "Wake"))
#> Using: cone as the data source
#> Last date available: 2022-03-04

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(ggplot2)

counties <- unique(dat$county)
entropy_values = dat %>% 
  group_by(county) %>% 
  dplyr::group_split() %>% 
  lapply( function(x) calculate_shannon(incidence = x$cases_daily) ) %>%
  unlist()
#> In order to use this function, the entropy package must be available
#> Loading required namespace: entropy
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
#> In order to use this function, the entropy package must be available
  
entropy_values = data.frame(county = counties, intensity = entropy_values)
  entropy_values %>% 
  filter(county %in% nccovid::triad_counties) %>% 
  ggplot(aes(reorder(county,intensity), intensity))+
  geom_point()+
  coord_flip()+
  labs(
    title = "Epidemic Intensity"
  )