3

I'm trying to create a Choropleth of a county using tracts as units.

Where it says "state_name", I have no idea what to put.

I've tried OH, OHIO, and the FIPS codes.

tract_choropleth(df, ohio, title = "census", legend = "",)

Each result ends with "Error in state_name %in% state.regions$region : object 'ohio' not found"

Tazz
  • 31
  • 2
  • 1
    All lower case, but you need it in quotes `tract_choropleth(df, "ohio", title = "census", legend = "")` – G5W Mar 26 '19 at 20:58
  • 1
    That solved it. Thanks. – Tazz Mar 26 '19 at 21:11
  • 1
    @Tazz In that case it would be nice to write an answer that states the solution, and accept it. That will help other people who stumble upon the question find the correct answer. – Ari Mar 26 '19 at 21:16
  • 1
    I will add it as an answer. – G5W Mar 26 '19 at 21:19

1 Answers1

2

The format for the names is a lower-case string. But it must be a string. The sample code has the unquoted ohio, so R is trying to interpret it as a variable name. Just quoting the string will make it work.

tract_choropleth(df, "ohio", title = "census", legend = "") 
G5W
  • 36,531
  • 10
  • 47
  • 80