I am currently trying to automate a process that seems simple, but I have to repeat the process 800 times. I have 2 datasets, each with 8 columns. One column is streamflow, and the other is a list of thresholds (each row has a different threshold). I want to know the number of days that the streamflow falls below the threshold. So far I've done this using mutate and ifelse.
lf1 <- Daily_average_Q %>%
mutate(lf1 = ifelse(Q1B < Thresholds$B1[1], '1', '0')
This gives me what I want for 1 threshold, but I have 100 thresholds that I need to use. I also need to do this over 8 sites, so I can't afford to do this 800 separate times. I just want the row number in Thresholds$B1[row#] to change automatically each time. I've tried looping with "for" but I can't figure out how to mutate and loop at the same time.
Thanks so much for any help!!