library(tidyverse) # Read Data in from wd icein_DRUM <- read.csv("./ice_in.csv") iceout_DRUM <- read.csv("./ice_out.csv") # Merge Ice on and Ice off to get ice duration ice <- merge(x = icein_DRUM, y = iceout_DRUM, by = c("DOW", "winter.year")) %>% mutate(max_duration = as.numeric(as.Date(max_ice_off_date) - as.Date(min_ice_on_date)), min_duration = as.numeric(as.Date(min_ice_off_date) - as.Date(max_ice_on_date))) #write.csv(ice, "./ice_duration.csv", row.names = F)