Code Monkey home page Code Monkey logo

statebins's People

Contributors

delabj avatar hansthompson avatar hrbrmstr avatar mkiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

statebins's Issues

How to reverse the color scale?

Hi, the plot generating the color scale from the direction that is the opposite of what I want. Is there a simple way to reverse the color scale?

Print state abbreviation even if value is NA

Right now the state abbreviations will not print if a value is NA:

library(statebins)
library(dplyr)
data(USArrests)

USArrests$state <- rownames(USArrests)
USArrests$Assault[1] <- NA

statebins(USArrests, value_col="Assault", name = "Assault", round=TRUE) +
    theme_statebins(legend_position="right")

Which returns this error:

1: In .sb_invert(gb$data[[1]]$fill, dark_label, light_label) :
  NAs introduced by coercion

It would be nice to still have the abbreviation printed -- possibly with a user-specified color.

Different size bins

Hi there

Great package. I wondered if there was an easy way to resize different bins? I'm after resizing the bins by population size, like this:

https://brilliantmaps.com/us-territories-resized/

It seems like resizing might not be too hard, but wondered whether dodging so that there is no overlap might be a bit trickier?

Best
Alan

using a tbl_df type (as generated by the dplyr package) causes an error

see http://stackoverflow.com/a/28122695/1273199

I get the error message "Error: state_data[, state_col] %in% state_coords[, merge.x] is not TRUE" when the data.frame is wrapped by the tbl_df class.

library(statebins)

t <- read.table(text= "year value state
2008 55.50628 Alabama
2008 67.52304 Alaska
2008 70.94418 Arizona
2008 57.89743 Arkansas
2008 71.40450 California
2008 75.29866 Colorado
2008 73.13052 Connecticut
2008 74.69418 Delaware",
header=TRUE, stringsAsFactors=FALSE)

class(t) # data.frame
statebins(t, state_col = "state", value_col = "value") # results in a statebins map

library(dplyr) # now repeat with tbl_df

t <- tbl_df(t) # convert to a tbl_df type
class(t) # "tbl_df" "tbl" "data.frame"
statebins(t, state_col = "state", value_col = "value") # yields this error message: "Error: state_data[, state_col] %in% state_coords[, merge.x] is not TRUE"

legend_position inconsistent

The help file states that the legend_position can be in the following positions...
legend_position | "none", "top", "left", "right" or "bottom" (defaults to "top")
But, if I add legend_position = "right" to my statebins_continuous() call, I get the following error:

Error in statebins_continuous... 'legend_position' must be either blank, 'none', 'top' or 'bottom'

Displaying multiple variables in a single bin

Background: I'm working on a shiny app that visualises US House and Senate voting patterns (with two types of scores, so four combinations). Currently I use the highcharter package however I want to switch to statebins - it looks really neat! Highcharter also takes forever to load every time a setting is changed - I'm hoping statebins would be faster (although not yet tested).

Request: Would it be possible to show more than one variable value in a single bin (w/o using faceting)? I really like the new facet functionality, but I also don't want to display 2x2 US maps to the user on a single page. I couldn't really find a working example (which might be telling), so I am attaching some hastily done photoshop'd possibilities:

bars
number
two_colurs

Not sure about the feasibility of any of these, but looking forward to your response! Cheers.

/Gokhan

abstracting to facets

I hesitate to ask this, given how quickly you responded (over the weekend!) to my request via twitter, but here goes--is it much work to allow statebins to accept a facet_wrap or facet_grid argument?

Generic Solution

Not being in the USA, but being very interested in the way this expresses data, would it be possible (read easy) to make this more general so I could have a data frame with a column variable equivalent to whree you have the US states initials (e.g. maybe Australian suburbs, geographic regions, etc) and produce the similar coloured grid result (i am thinking of e.g. population, average wages, number living alone, etc)?

Thanks
Dan Raymond

Removing Unwanted Whitespace

Following up from Twitter; how to get rid of the white background at the edges that resists all my attempts at removing them?

library(shinydashboard)
library(ggplot2)

ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(fluidPage(fluidRow(
                      plotOutput("statebins1")),
                      fluidRow(
                      plotOutput("statebins2"))
                      ))
)

server <- function(input, output) {
output$statebins1 <- renderPlot({

us.data <- data.frame(cbind(state.abb, state.area), stringsAsFactors = FALSE)
us.data$state.area <- as.numeric(us.data$state.area)
statebins::statebins(state_data = us.data, state_col = "state.abb", value_col = "state.area")

})

output$statebins2 <- renderPlot({

statebins::statebins(state_data = us.data, state_col = "state.abb", value_col = "state.area") +
           theme(axis.text.x = element_blank(), axis.text.y = element_blank(), axis.ticks = 
           element_blank(), panel.grid.minor = element_blank(), panel.grid.major = element_blank(),
           plot.background = element_rect(fill = "#ecf0f5"))

})

}

shinyApp(ui, server)

warning: `show_guide` has been deprecated

Hi there,

I'm trying to recreate the CDC State FluView map you created using statebins() in your cdcfluview GitHub repo example code (I've made no significant changes). I get the following warning:

Warning: show_guide has been deprecated. Please use show.legend instead.

Looking at the statebins.R file, I see that there are 3 lines where show_guide=FALSE is specified. I imagine that replacing this with show.legend=FALSE will eliminate this warning.

Show values and state name in the map?

Hi, is it possible to let the map show not only state name, but also the values? Maybe a bigger font for state and then a smaller text for the value?

Thanks in advance.

Statebins as sp object?

How hard would it be to create statebins as an sp object with reasonable lat and long values? I'm thinking about modifying geom_map() so it can take sp objects as input, and switching between actual state borders and binned border would be interesting.

(That would also make it easy to generalise statebins to other shapes)

Error in theme_bw

I'm following the example on https://rud.is/b/2017/11/18/statebins-reimagined/

When I run the code

statebins(USArrests, value_col="Assault", name = "Assault") +

  • theme_statebins(legend_position="right")
    

I get the error below

Error in theme_bw(base_family = base_family, base_size = base_size, base_line_size = base_line_size, :
unused arguments (base_line_size = base_line_size, base_rect_size = base_rect_size)

devtools::session_info()
Session info ------------------------------------------------------------------------
setting value
version R version 3.3.3 (2017-03-06)
system x86_64, mingw32
ui RStudio (1.1.383)
language (EN)
collate English_United States.1252
tz America/New_York
date 2017-11-19

Packages ----------------------------------------------------------------------------
package * version date source
colorspace 1.3-2 2016-12-14 CRAN (R 3.3.2)
devtools 1.12.0 2016-06-24 CRAN (R 3.3.2)
digest 0.6.10 2016-08-02 CRAN (R 3.3.2)
ggplot2 2.2.1 2016-12-30 CRAN (R 3.3.2)
gtable 0.2.0 2016-02-26 CRAN (R 3.3.1)
labeling 0.3 2014-08-23 CRAN (R 3.3.0)
lazyeval 0.2.0 2016-06-12 CRAN (R 3.3.2)
memoise 1.0.0 2016-01-29 CRAN (R 3.3.2)
munsell 0.4.3 2016-02-13 CRAN (R 3.3.1)
plyr 1.8.4 2016-06-08 CRAN (R 3.3.1)
RColorBrewer 1.1-2 2014-12-07 CRAN (R 3.3.0)
Rcpp 0.12.8 2016-11-17 CRAN (R 3.3.2)
rlang 0.1.4 2017-11-05 CRAN (R 3.3.3)
scales 0.5.0 2017-08-24 CRAN (R 3.3.3)
statebins * 1.3.0 2017-11-19 Github (1d93f7a)
tibble 1.3.4 2017-08-22 CRAN (R 3.3.3)
withr 1.0.2 2016-06-20 CRAN (R 3.3.2)
yaml 2.1.14 2016-11-12 CRAN (R 3.3.3)

geom_rrect() as an exportable object

I'd love to be able to use geom_rrect(), but (as a new package developer) I'm really struggling to make use of it in a way that would be allowed on CRAN. Is it possible to make it exportable, please? Thanks so much!

Problem with plot_title

If I try adding a plot title to the help example:

data(USArrests)
USArrests$state <- rownames(USArrests)
statebins(USArrests, value_col="Assault", text_color="black", font_size=3,
          plot_title = "1973 Assault arrests",
          legend_title = "Assault", legend_position="bottom")

I get no plot, no error, and the following output in the console:

TableGrob (2 x 1) "arrange": 2 grobs
    z     cells    name                grob
    1 (1-1,1-1) arrange      gtable[layout]
sub 2 (2-2,1-1) arrange text[GRID.text.716]

Is anyone else having this problem, or maybe something with my setup?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.