Skip to content

Instantly share code, notes, and snippets.

@solmos
Last active August 14, 2020 08:13
Show Gist options
  • Save solmos/71c4ad9039e3fa0635616ae668593fda to your computer and use it in GitHub Desktop.
Save solmos/71c4ad9039e3fa0635616ae668593fda to your computer and use it in GitHub Desktop.
readFireCounts <- function(file) {
fire_counts <- read_delim(file, delim = ";") %>%
rename(date = "ACQ_DATE") %>%
count(date) %>%
as_tibble()
dates_expanded <- seq(min(fire_counts$date), max(fire_counts$date), by = "days")
fires_full <- tibble(date = dates_expanded) %>%
left_join(fire_counts) %>%
mutate(
day = day(date),
month = month(date, label = TRUE),
year = year(date),
year_fct = factor(year, levels = 2012:2019, labels = 2012:2019, ordered = TRUE),
n = replace_na(n, 0)
)
fires_full
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment