0

I'm trying to create a choropleth map using a .shp shapefile and a csv. I'm stuck on the inner_join step and keep receiving the error below, even after using colClass function to change the variable type to match my shapefile data. Anyone know what the issue may be?

ods_total<-read.csv("ods.csv",stringsAsFactors = FALSE,colClasses = c("STATE_FIPS"="integer"))

> typeof(ods_total$STATE_FIPS)
[1] "integer"

> typeof(map$STATE_FIPS)
[1] "integer"

> map_data<-inner_join(map,ods_total)

Joining, by = c("STATE_NAME", "DRAWSEQ", "STATE_FIPS")
**Error: Can't join on 'STATE_FIPS' x 'STATE_FIPS' because of incompatible types (factor / integer)**"
Ritchie Sacramento
  • 29,890
  • 4
  • 48
  • 56
  • `map$STATE_FIPS` is a factor. Compare `class(map$STATE_FIPS)` to `typeof(map$STATE_FIPS)`. Factors are stored internally as a vector of integers. – Ritchie Sacramento Oct 11 '19 at 05:49
  • See [here](https://stackoverflow.com/questions/35689019/confused-about-types-in-r-typeof-returns-integer-for-something-that-is-clearly). – Ritchie Sacramento Oct 11 '19 at 06:01

0 Answers0