View source: R/calculation_shannon.R
calculate_shannon | R Documentation |
Calculate Shannon Index for a Series
calculate_shannon(incidence)
incidence |
numeric, the case incidence |
double, the intensity of epidemic calculated via Shannon index
dat <- nccovid::get_covid_state(c("Guilford", "Forsyth", "Mecklenburg", "Wake"))
library(dplyr)
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()
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"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.