Advanced choroplethr – Customized Bins

April 5, 2017
By

(This article was first published on R Analysis – Analyst at Large, and kindly contributed to R-bloggers)

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 on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Sponsors

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)