1

I am trying to label counties using choroplethr. Some posts on the topic exist but do not detail sufficiently how this is done.

My reproducible example/code follows. How would I change my code so that it displays labels for my counties? If needed, the label variable I'd like to use is "CountyName". Setting c$show_labels to TRUE doesn't seem to work.

library(RCurl)
library(choroplethr)
library(choroplethrMaps)
HSmap<-getURL("https://raw.githubusercontent.com/bac3917/Cauldron/master/NeedsSurv_MAP.csv")
HSmap<-read.csv(text=HSmap)
library(plyr)
HSmap<-plyr::rename(HSmap,c(fipst="region") )             #rename variables
HSmap<-plyr::rename(HSmap,c(ChallSum_mean="value") )      #rename variables


county_choropleth
function (df, title = "", legend = "", num_colors = 5, zoom = NULL) 
{
      c = CountyChoropleth$new(df)
      c$title = title
       c$legend = legend
       c$set_num_colors(num_colors)
       c$set_zoom(zoom)
       c$show_labels = TRUE
       Map1=c$render()
}

Map1<-county_choropleth(HSmap, 
              title = "2017 Survey - Average Things per Staff, by County",
              legend="Number of Responses",
              state_zoom = "pennsylvania", 
              reference_map = FALSE) 

Map1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.