I'm trying to plot air mass back trajectories. I currently have code, which works perfectly for a single point, looping through running the model every three hours. Here's the key part of that code:
lapply(files, function(x) file.remove(x))
start <- paste(year, "-01-01", sep = "")
end <- paste(year, "-12-31 18:00", sep = "")
dates <- seq(as.POSIXct(start, "GMT"), as.POSIXct(end, "GMT"), by = "3 hour")
for (i in 1:length(dates)) {
year <- format(dates[i], "%y")
Year <- format(dates[i], "%Y") # long format
month <- format(dates[i], "%m")
day <- format(dates[i], "%d")
hour <- format(dates[i], "%H")
However, I've been trying to add an extra layer to this. Currently, it loops through and runs the calculation every three hours. Now, for each of those three hour intervals, I need it to use a new longitude and latitude for the calculation. Any advice as to how I could go about adding this detail?
I was thinking of using something along the lines of:
purrr::map_2(long, lat, ~some_function_of(.x, .y))
…but despite hours looking at cheat sheets trying to teach myself how to use this function I'm getting nowhere.
Any suggestions?