I have a multiband raster stack and I want to find the band number of the maximum value for each pixel. For this, I have used the following code:
#Set working directory
setwd("E:/Red Panda/TIF")
library(raster)
#Get the names of all the files with extension ".tif" of the folder
files