I feel like many similar questions have been asked but I haven't found a solution to my problem yet in the related questions.
I am trying to change the colors on my map using spplot and the col.region command.
I have tried setting up a palette with the RColorBrewer package. I have tried using various values for the n: 5,6,7 (I am using 5 quantiles for my cuts) and even 1 to see if it would result in any observable change, but to no avail. I have also changed the choice of color several times but it also didn't bring any change. I have also tried setting up a color function the colorRampPalette function but also unsuccessfully.
The data I'm using can be downloaded here (sorry, I couldn't figure out how to upload it with the question) : http://www.data.drees.sante.gouv.fr/ReportFolders/reportFolders.aspx, by typing "APL" in search bar and taking the first excel file (2015); apologies can't manage to link it properly either)
My code is the following:
library(maptools)
library(raster)
library(RColorBrewer)
library(readxl)
library(classInt)
apl15 <- read_excel("DATA USED")
france_com<- getData(name = "GADM",
country="FRA",
level=5)
paca <- subset(fr_com,NAME_1=="Provence-Alpes-Côte d'Azur")
apl15 <- data.frame(apl15)
names(apl15) <- c("code_com","name_com","apl","apl_young","pop_com","dept","apl*pop")
id_paca <- match(paca$NAME_5,apl15$name_com)
key_paca<- apl15[id_paca,"apl"]
paca$apl <- key_paca
apl.qt <- classIntervals(paca$apl,
n=5,
style="quantile")
br <- apl.qt$brks
offs <- 0.0000001
br[1] <- br[1] - offs
br[length(br)] <- br[length(br)] + offs
paca$apl_q <- cut(paca$apl,br)
display.brewer.all(type="seq")
my.palette <- brewer.pal(6, "OrRd")
spplot(paca,"apl_q",
col.region=my.palette,
main="APL en PACA", cex.=.7)
I expect this map but with colors corresponding to the palette I have selected.
my data mapped onto a region:
.
Thanks in advance for any help!