{"action":"created","issue":{"url":"https://api.github.com/repos/rstudio/leaflet/issues/169","labels_url":"https://api.github.com/repos/rstudio/leaflet/issues/169/labels{/name}","comments_url":"https://api.github.com/repos/rstudio/leaflet/issues/169/comments","events_url":"https://api.github.com/repos/rstudio/leaflet/issues/169/events","html_url":"https://github.com/rstudio/leaflet/issues/169","id":102857343,"number":169,"title":"help creating choropleth map?","user":{"login":"ignacio82","id":1833309,"avatar_url":"https://avatars.githubusercontent.com/u/1833309?v=3","gravatar_id":"","url":"https://api.github.com/users/ignacio82","html_url":"https://github.com/ignacio82","followers_url":"https://api.github.com/users/ignacio82/followers","following_url":"https://api.github.com/users/ignacio82/following{/other_user}","gists_url":"https://api.github.com/users/ignacio82/gists{/gist_id}","starred_url":"https://api.github.com/users/ignacio82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignacio82/subscriptions","organizations_url":"https://api.github.com/users/ignacio82/orgs","repos_url":"https://api.github.com/users/ignacio82/repos","events_url":"https://api.github.com/users/ignacio82/events{/privacy}","received_events_url":"https://api.github.com/users/ignacio82/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-24T18:13:57Z","updated_at":"2015-08-25T22:00:57Z","closed_at":null,"body":"My data looks like this:\r\n\r\n    states <-\r\n      structure(\r\n        list(\r\n          State = c(\r\n            \"CA\", \"TX\", \"IL\", \"FL\", \"NY\", \"OH\",\r\n            \"NJ\", \"GA\", \"MI\", \"PA\", \"MA\", \"CO\", \"AZ\", \"NC\", \"VA\", \"WA\", \"IN\",\r\n            \"MD\", \"MN\", \"WI\", \"MO\", \"TN\", \"IA\", \"KY\", \"LA\", \"SC\", \"CT\", \"AL\",\r\n            \"KS\", \"OR\", \"OK\", \"AR\", \"NV\", \"UT\", \"NE\", \"ID\", \"MS\", \"DC\", \"NM\",\r\n            \"NH\", \"ME\", \"AK\", \"RI\", \"MT\", \"HI\", \"WV\", \"SD\", \"ND\", \"DE\", \"VT\",\r\n            \"WY\", \"PR\", \"GU\", \"VI\", \"MP\", \"AS\", \"na\", \"MH\", \"FM\", \"PW\"\r\n          ),\r\n          count = c(\r\n            1590533L, 1016328L, 754535L, 742603L, 714205L,\r\n            538719L, 477278L, 452064L, 437162L, 428616L, 420332L, 391084L,\r\n            380853L, 354601L, 342533L, 335505L, 294670L, 286026L, 273427L,\r\n            246172L, 238968L, 236037L, 235030L, 209514L, 199013L, 191707L,\r\n            185521L, 179931L, 163477L, 159862L, 142610L, 136006L, 120111L,\r\n            117338L, 112671L, 106176L, 102564L, 100168L, 97496L, 69881L,\r\n            69508L, 68684L, 65631L, 62109L, 61123L, 57300L, 57254L, 56091L,\r\n            51696L, 33944L, 32136L, 4822L, 598L, 468L, 49L, 19L, 17L,\r\n            11L, 2L, 1L\r\n          )\r\n        ), .Names = c(\"State\", \"count\"), class = c(\"tbl_dt\",\r\n                                                   \"tbl\", \"data.table\", \"data.frame\"), row.names = c(NA,-60L), .internal.selfref = <\r\n          pointer:0x0000000000320788 >\r\n      )\r\n    \r\nI would like to create a map of the US using count to color each state. I can create a map of the US with this code:\r\n\r\n    library(leaflet)\r\n    library(maps)\r\n    mapStates = map(\"state\", fill = TRUE, plot = FALSE)\r\n    leaflet(data = mapStates) %>% addTiles() %>%\r\n      addPolygons(fillColor = topo.colors(10, alpha = NULL), stroke = FALSE)\r\n\r\nbut, I'm not sure how to change that code to tell it to use my data to color the states. \r\n\r\nThanks for the help!"},"comment":{"url":"https://api.github.com/repos/rstudio/leaflet/issues/comments/134754732","html_url":"https://github.com/rstudio/leaflet/issues/169#issuecomment-134754732","issue_url":"https://api.github.com/repos/rstudio/leaflet/issues/169","id":134754732,"user":{"login":"jcheng5","id":129551,"avatar_url":"https://avatars.githubusercontent.com/u/129551?v=3","gravatar_id":"","url":"https://api.github.com/users/jcheng5","html_url":"https://github.com/jcheng5","followers_url":"https://api.github.com/users/jcheng5/followers","following_url":"https://api.github.com/users/jcheng5/following{/other_user}","gists_url":"https://api.github.com/users/jcheng5/gists{/gist_id}","starred_url":"https://api.github.com/users/jcheng5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcheng5/subscriptions","organizations_url":"https://api.github.com/users/jcheng5/orgs","repos_url":"https://api.github.com/users/jcheng5/repos","events_url":"https://api.github.com/users/jcheng5/events{/privacy}","received_events_url":"https://api.github.com/users/jcheng5/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T22:00:57Z","updated_at":"2015-08-25T22:00:57Z","body":"Try using `sp::merge` to combine `states` with `my_counts`. http://www.inside-r.org/packages/cran/sp/docs/merge"}}