selectRange function

Select values from rasters in a stack based on values in another raster