calculate_shannon: Calculate Shannon Index for a Series

View source: R/calculation_shannon.R

calculate_shannonR Documentation

Calculate Shannon Index for a Series

Description

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"))

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"
	)


nctriadresearch/nccovid documentation built on April 9, 2023, 7:03 a.m.