```
r <- raster(ncols=36, nrows=18)
values(r) <- runif(ncell(r))
# reclassify the values into three groups
# all values > 0 and <= 0.25 become 1, etc.
m <- c(0, 0.25, 1, 0.25, 0.5, 2, 0.5, 1, 3)
rclmat <- matrix(m, ncol=3, byrow=TRUE)
rc <- reclassify(r, rclmat)
# for values >= 0 (instead of > 0), do
rc <- reclassify(r, rclmat, include.lowest=TRUE)
# equivalent to
rc <- reclassify(r, c(-Inf,0.25,1, 0.25,0.5,2, 0.5,Inf,3))
```

Run the code above in your browser using DataCamp Workspace