I have a raster Z with elevation values (0, 0.12, 2.12), which I created myself in R. I want to produce a land-use raster from these elevation values, i.e. if Z<0.12, I assign land-use class 1 to it, if Z== 0.12, I assign land-use class 2 and if z>0.12, land-use class 3 and so on. I realized that using the method
Z[Z<0.12]<-1, Z[Z==0.12]<-2, Z[Z>0.12]<-3
only works for two cases. If there are 3 cases (like in my case), the whole raster just fills up with the values from the last expression, in this case, 3.
What can I do to prevent this behaviour or is there any other method to replace the values and not have this effect?