I have thousands of .tif files which contain daily temperature data. The file names include the date in a format like this tminYYYYMMDD.tif, here is a sample:
tmin19810707.tif
tmin19810508.tif
tmin19810314.tif
tmin19810227.tif
I only need the data from June (06), July (07) and August (08) form all those years. How can I select and use for further processing only files that are from those months?
>Solution :
We can use substr for a base R solution:
x <- c("tmin19810707.tif", "tmin19810508.tif", "tmin19810314.tif",
"tmin19810227.tif")
output <- x[substr(x, 9, 10) %in% c("06", "07", "08")]
output
[1] "tmin19810707.tif"