#' Replace daily inc with NA in specific rows
#'
#' @param results a result data.frame with location,
#' date, cum and inc as columns.
#' @param adjustments a adjustment case data.frame
#' @return a data.frame with the same set of columns and
#' NAs on adjustment cases
#' @export
fill_na <- function(results, adjustments) {
adjustments$date <- as.character(adjustments$date)
results %>%
dplyr::rowwise() %>%
dplyr::mutate(
# for each row, if date is in adjustment date and location is in adjustment states
inc = ifelse(date %in% adjustments$date[adjustments$location == location] |
# if first two digits of county fips is the state fips of adjustment states
date %in% adjustments$date[adjustments$location == stringr::str_sub(location, start = 1, end = 2)], NA_integer_, inc)
) %>%
dplyr::ungroup()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.