Hello everyone, hope you can help me trying to avoid DRY in my code.
I am trying to evaluate the sea temperature. I have results with this
first code, but I want to improve with a loop function, just I don't know how to convert to "for function".
#open image library(oce) library(ncdf4) fn <- "C:/images/gertmo/figure_sun1.nc" vart <- nc_open(fn) ray1 <- ncvar_get(vart,"degrees") nc_close(vart) final1 <- ray1[c(ocean)] #Here "ocean" was defined in other object before but is a constant in all files" fn <- "C:/images/gertmo/figure_sun2.nc" vart <- nc_open(fn) ray2 <- ncvar_get(vart,"degrees") nc_close(vart) final2 <- ray2[c(ocean)] .. The following for 30 days. #then using "cbind", to get a file with all the variables "final" SUN2015 <- cbind(final,final2,...)
The files are in the same folder, and in numerically order.
Thanks so much for your kind suggestions.