3

I'm trying to replicate the map shown in Ari's ACS talk using tract_choropleth. However, the codes keep returning an Error message. I have requested the api key and other functions like state_choropleth() and county_choropleth() were working just fine.

library(choroplethr)
library(choroplethrMaps)
#api.key.install(DONE)

ny_tract = get_tract_demographics("new york", endyear = 2015)
ny_tract$value = ny_tract$per_capita_income

tract_choropleth(ny_tract, state_name="new york", title='2015 map of NY', 
legend = "dollars", num_colors = 1, county_zoom = 36061)

The Error message is

Error in maptools::unionSpatialPolygons(cp, attr[,region]): isTRUE(gpclibPermitStatus()) is not TRUE

I can see that the data frame ny_tract was loaded with many NA introduced by coercion warnings.

Thank you for your help.

Rosemary
  • 95
  • 1
  • 9
  • 1
    There is a typo in your question. You wrote `tract_cholopleth` when you meant to write `tract_choropleth`. I tried to edit it, but it said "edits must be at least 6 characters". – Ari Oct 30 '18 at 13:38
  • 1
    Yes, it is a typo and I changed it. Thank you! – Rosemary Oct 30 '18 at 19:04

1 Answers1

2

The error is due to gpclibPermitStatus() returning FALSE.

Unfortunately, this is a common error that comes up when working with choroplethr. I once gave a lengthy answer to the question here.

The short answer is to type the following:

install.packages("gpclib")
library(maptools)
gpclibPermit()
Ari
  • 1,819
  • 14
  • 22
  • 2
    For anyone else reading as well - on Windows I had to install RTools to compile gpclib, and once that completed this answer worked. – Hatt Oct 30 '18 at 14:45
  • Thanks. I am using a mac, but it's good to know how it works with Windows. – Rosemary Oct 30 '18 at 18:52