简体   繁体   中英

Choroplethr produces no graphical output that I can see when reference_map = TRUE

This code draws the stock choroplethr map as it should:

ca_tract_choropleth(df_ca_tract_demographics,
+ title = "2013 Los Angeles Census Tract\\n Percent White",
+ legend = "%",
+ num_colors = 9,
+ county_zoom = 6037)

This code produces a source URL that shows the reference map only and a blank plots tab in R-Studio:

ca_tract_choropleth(df_ca_tract_demographics, + title = "2013 Los Angeles Census Tract\\n Percent White",
+ legend = "%",
+ num_colors = 9,
+ county_zoom = 6037,
+ reference_map = TRUE)

I am running:

R 3.6.0
R Studio 1.2.1335
OSX 10.14.6
choroplethr 3.6.3

Does anyone have any ideas?

I think that there are a few things going on here.

  1. While you don't mention it explicitly, I believe that you are probably using the ChoroplethrCaCensusTract package (that is the only place I know that has a function named ca_tract_choropleth ). Please note that that package has been deprecated in favor of the newer tract_choropleth function in the main choroplethr package. See this post for usage instructions.

  2. Your bug seems specific to creating reference maps. Note that I recently wrote a blog post about an issue related to this feature. Namely, Google now requires you to register with their API in order to use reference maps.

  3. It would have helped if you made a more reproducible version of the code so it would be easier for people to run. Here is an example:

# install the package
# install.packages("devtools")
library(devtools)
install_github("arilamstein/choroplethrCaCensusTract@v1.2.0")
library(choroplethrCaCensusTract)

# load the data
data("df_ca_tract_demographics")
df_ca_tract_demographics$value = df_ca_tract_demographics$total_population

# this works
ca_tract_choropleth(df_ca_tract_demographics, title = "2013 Los Angeles Census Tract\n Percent White",
                    legend = "%",
                     num_colors = 9,
                     county_zoom = 6037,
                     reference_map = FALSE)

# this does not work - why?
ca_tract_choropleth(df_ca_tract_demographics, title = "2013 Los Angeles Census Tract\n Percent White",
                    legend = "%",
                     num_colors = 9,
                     county_zoom = 6037,
                     reference_map = TRUE)

Finally, this bug is reinforcing to me that I should probably create a free, online book that has all the current documentation for choroplethr (similar to the various books Hadley has put out). I have a lot of blog posts, but some of them are (of course) outdated, but a newcomer can't be expected to search through all of them to find their answer. I also have a number of paid courses, but they are time consuming to update. A free textbook on choroplethr would probably be easier for everyone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM