Here is a really simple example
library(raster)
data(volcano)
volcanoR <- raster(volcano)
#making colors below 100 red and above 180 blue in this example
breakpoints <- c(94,100,120,140,160,180,195)
colors <- c("red","white","white","white","white","blue")
plot(volcanoR,breaks=breakpoints,col=colors)

You just need to pass the plot a vector of break points and a vector of colors to match the breakpoints. Check out the RColorbrewer package for some very nice built in color ramps. Also check out the classInt package for making the breakpoints.
imageto solve this, but I thought that plot should do it, too. – Rodrigo Apr 27 '21 at 15:40