I would like to avoid copy pasting in my code, and I would like to use a string as a name of multiple files.
bands <- c('B1', 'B2', 'B3', 'B4', 'B5')
for (band in bands){
path <- paste0('./data/landsat/LE07_L2SP_012054_20120217_20200909_02_T1', '_SR_', band, '.tif')
band <- raster(path)
}
In this case, I understand that I am making a raster called "band" five times. Is there any way I could end up with 5 files called respectively 'B1', 'B2', 'B3', 'B4', 'B5'?