In Mathematica there is the command Clip[x, {min, max}] which gives x for min<=x<=max, min for x
Clip[x, {min, max}]
x
min<=x<=max
min
I believe that would be clamp() from the raster package.
raster
library(raster) clamp(x, lower=-Inf, upper=Inf, ...)