I'm getting "c("region", "value") %in% colnames(user.df) are not all TRUE" error while creating a choropleth of US ZIP codes using choroplethrZip package.
I am trying to plot the zip codes of the US map based on the label value in that zip code, using the above packages. I am trying to use the following code but doesn't work
#install.packages("devtools")
library(devtools)
#install_github("choroplethr", "trulia")
library(choroplethr)
#install_github('arilamstein/[email protected]')
library(choroplethrZip)
temp <- read.table("data.txt")
zip_choropleth(temp)
data.txt looks like
region value
00601 15
00602 42
00603 97
00604 3
. .
. .
The function
zip_choropleth
expectsdf
to beHowever, the way you read the data,
df
does not have this property:And this is what the error message tells you:
This is just a complicated way of saying that the column names of
df
are notregion
andvalue
as they are expected to be.The issue here is that the column headers in the file are read as if they were part of the data. But this behaviour can be easily changed: