I recently stumbled upon the setValues()
form the raster
package, but I am wondering what the use case of this function is. Is there any advantage compared to normal subsetting and indexing:
r <- raster(ncol=10, nrow=10)
#setValues Function
r <- setValues(r, values=1, index=10)
#Normal indexing
r[10] <- 1
Both ways yield in the same result. However the documentation states that:
While you can access the 'values' slot of the objects directly, you would do that at your own peril because when setting values, multiple slots need to be changed; which is what these functions do.
What does the author mean by peril here? And what slots remain unchanged, when I use normal subsetting and not the setValues function or is there any advantage in terms of perfomance?