0

How can I change the map colors in a merged map file? Did I miss installing/calling a package? And at which point to I insert the command I need?

library(ggplot2)
library(rgeos)
library(plyr)
library(rgdal)
library(RColorBrewer)
ph<- readOGR ("PHL_adm", "PHL_adm1")
id <- c(34, 35, 39, 61)
id
phsub <- ph [id, ]
summary (phsub)
plot (phsub)
Poverty <- read.csv("Poverty.csv", header=T, sep=",")
reg_merge <-  merge(phsub, Poverty, by.x="NAME_1", by.y="Province")
names(reg_merge)
pal<-brewer.pal(4,"YlOrRd")
class(pal)
spplot(reg_merge, "Poverty")

I tried spplot(reg_merge, "Poverty", col="orange") but it only changed the outline of the map.

Maurits Evers
  • 49,617
  • 4
  • 47
  • 68
Kris
  • 1
  • 1
  • 1
    I find your question hard to adress because your code is not reproducible; it calls on files that are not accesible to anyone. Read https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5965451#5965451 to get some ideas for making easier to find a solution. – David Jorquera Dec 13 '18 at 02:53
  • This is my data for "Poverty" structure(list(Province = structure(5:1, .Label = c("Abra", "Ilocos Norte", "Ilocos Sur", "La Union", "Pangasinan"), class = "factor"), Poverty = c(11.2, 9.2, 9.5, 3.3, 0)), class = "data.frame", row.names = c(NA, -5L )) – Kris Dec 13 '18 at 03:31
  • The other dataset is too long though. It's a dataset for the map of the Philippines where I chose only the provinces included in the "Poverty" data – Kris Dec 13 '18 at 03:33
  • This question may be of help: https://stackoverflow.com/questions/25918012/rcustom-color-palette-in-map-with-spplot – Stedy Dec 13 '18 at 04:51
  • have you tried `fill="orange"` instead? – Andy Baxter Dec 13 '18 at 09:51

0 Answers0