trulia / choroplethr

choroplethr simplifies the creation of choropleths (thematic maps) in R
Other
141 stars 53 forks source link

Bucketing alternatives #5

Closed pssguy closed 10 years ago

pssguy commented 10 years ago

The only option currently, is to have buckets having an equal number of values in. When populations are skewed this is a bit misleading For instance, at http://mytinyshinys.com/acs/ with settings state;other; and 9 groups, the first 7 groups cover 0-4,16% and the final two 4.16-13.91% It would be nice to have the ability to determine maximum and minimum values and then divide the range by the number of buckets . So in this example, each bucket would have a range of 13.91/9 = 1.55. Ideally the user of a shiny app could toggle between alternatives

In addition, for someone producing a static map in R, the ability to set the ranges to more rational steps based on the data would be helpful. For example, if I wanted to publish the map referred to above I would like to set a vector of say (1,2,3,5,10,15) which would result in 6 groupings with the first 0-1%, 1-2% etc. The legend would look a lot neater and any explanatory text would read better when referring to the map

arilamstein commented 10 years ago

I am currently working on this feature. Are you interested in testing a development version of it when I am ready to have testers?

The example I am using is highlighting the counties which are the highest and lowest "1%", since that is in the news a lot.

pssguy commented 10 years ago

Sure. Glad to help out

alamstein-trulia commented 10 years ago

This is now working in the beta version of version 1.2.0. Installation instructions as well as overviews of the new functions are available here: https://groups.google.com/forum/#!topic/choroplethr/XduwUuH_Mo8. Please let me know what you think. The documentation for the new functions in R have example usage.

pssguy commented 10 years ago

OK I will look at this in next day or two and get back with any comments

pssguy commented 10 years ago

I have tried out the new functions and they all seem to work fine. Congrats A few initial thoughts a) I like the cut implementation . Good flexibility and with extra ggplot methods aspects like the legend can be made more readable. It would still be better if the default, continuous color went from light to dark as volumes increased b) Having the dfStateBind data.frame for use in tables, etc is great c) Am I right that if I want to map just one state with county data then I still need to use the old functions? d) It would be extremely helpful if using this in a shinyApp to initially be able to return the column list from a table separately (you are obviously collecting it in your code) say as a vector from a get_acs_columns(). This could then be displayed to the user as a set of checkboxes and the choice added as an argument of the get_acs_df(). If there was only one column then get_acs_df() could be triggered automatically instead of get_acs_columns() For an example table B02001. What I envisage is having a subset of the most illuminating ACS tables as the initial selection. This would be created independently of your package The user then gets from the chosen table a list of column choices etc... Hope I have made this clear enough

alamstein-trulia commented 10 years ago

Thanks for the feedback. I'll try to answer each of your points:

a) Thank you. I would like to add more flexibility with rendering colors as well. I am currently using ggplot2 defaults as well as the brewer scale. It is on my list to address this issue, but I believe that you also created another issue for it, so I was planning to address it then. b) Thank you. c) No. If you type ?render_choropleth you will see that the last parameter is states=states.abb - just send in a vector of postal codes that you want and it should "just work".
d) Can I ask you to create a separate issue for this? Keeping issues small and focused helps me to complete them.

If you feel that this particular issue is resolved by the new features in 1.2 can I ask you to close it? v1.2 was just accepted by CRAN. It will probably take a few days for it to propagate to all the mirrors. I am also going to start working on a blog post explaining all the new features.

pssguy commented 10 years ago

Yep sorry to over-elaborate