if I have this raster
r1 <- raster(nrow=10, ncol=10)
vv=c(1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5,1:5)
values(r1) <- vv
How to do this:
replace by
3 1
5 2
2 3
4 5
1 4
I know we can do
r1[r1==3]=1 but then it will problematic with values already = 1 (that I need to replace by 4!!