In the example below, I'd like to colour values above 100 in a blue colour scheme (from light blue for the closest to 100 to dark blue for the max) and values below 100 in a warm colour range (from yellow for the closest to 100 to red for the min). See example of colour range below. Could someone kindly help me on that? I have tried a few different ways (incl. the one below) but unsuccessfully.Thanks a lot!
#library
library(raster)
library(ggplot2)
library(maptools)
data("wrld_simpl")
#sample raster
r <- raster(ncol=36, nrow=18)
r[] <- (-ncell(r)/2+1):(ncell(r)/2)
plot(r)
var_df <- as.data.frame(rasterToPoints(r))
#plotting
p <- ggplot()
p <- p + geom_raster(data = var_df , aes(x = x, y = y, fill = layer))
p <- p + coord_equal()
p <- p + scale_fill_gradient2(low = muted("red"), mid = "white",
high = muted("blue"), midpoint = 100)
p