Advanced choroplethr – Customized Bins

[This article was first published on R Analysis – Analyst at Large, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Choroplethr is great to use straight out of the box, but sometimes you’ll want to fix up some of the details.  In a previous post, I showed how to modify the color scheme.  Now I’ll explain how to set up customized bins when using choroplethr.  If you just run a choroplethr function, you will get the automatically generated bins:

You can pretty easily modify the number of bins (use 1 for continuous), but you will still just get automatically generated breakpoints for the number of bins you selected:

If you want to customize these breakpoints, then you will want to go into the data frame, create a new variable to store your value bins, and then overwrite the “value” variable.  Essentially, you are changing the data in the data frame to suit your purposes.  Here you can see that I’ve done that and applied breakpoints of $0-$10K, $10K-$20K, $20K-$30K, $30K-$40K, and $40K+:

Full R Code:

To leave a comment for the author, please follow the link and comment on their blog: R Analysis – Analyst at Large.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)