I'm trying to stack 21 raster files using this code:
setwd("D:/LANDSAT8/2016/LC8221077/all/")
img = stack(list.files(pattern=".TIF$"))
names(img) <- c(paste0("B", 1:21, coll = ""))
But when I run it, it show's this error message:
Error in rep.int(names(x), lengths(x)) : invalid 'times' value
How can I solve it?