I want to add black borders to a county choropleth map I have created of New Jersey. Here is my current code:
county_choropleth(tni_data,
state_zoom = "new jersey",
reference_map = TRUE,
num_colors = 8) +
scale_fill_brewer(palette="YlOrRd") +
labs(title = "DV/SV Incidents by New Jersey County",
legend = "DV/SV Incidents (total)") +
geom_polygon(aes(fill=value), color="black")
Based on this earlier question.
I am getting this error:
Error in FUN(X[[i]], ...) : object 'value' not found
Any advice on what might be wrong would be very appreciated!
UPDATE: Including minimal reproducible example!
tni_data <- structure(list(county = c("atlantic", "bergen", "burlington",
"camden", "cape may", "cumberland", "essex", "gloucester", "hudson",
"hunterdon", "mercer", "middlesex", "monmouth", "morris", "ocean",
"passaic", "salem", "somerset", "sussex", "union", "warren"),
value = c(3187, 3410, 3747, 6532, 1339, 2510, 6420, 2417,
2656, 570, 2139, 4336, 3514, 1802, 4372, 2451, 773, 1840,
1265, 3054, 1311), region = c(34001, 34003, 34005, 34007,
34009, 34011, 34013, 34015, 34017, 34019, 34021, 34023, 34025,
34027, 34029, 34031, 34033, 34035, 34037, 34039, 34041),
county.fips.character = c("34001", "34003", "34005", "34007",
"34009", "34011", "34013", "34015", "34017", "34019", "34021",
"34023", "34025", "34027", "34029", "34031", "34033", "34035",
"34037", "34039", "34041"), state.name = c("new jersey",
"new jersey", "new jersey", "new jersey", "new jersey", "new jersey",
"new jersey", "new jersey", "new jersey", "new jersey", "new jersey",
"new jersey", "new jersey", "new jersey", "new jersey", "new jersey",
"new jersey", "new jersey", "new jersey", "new jersey", "new jersey"
), state.fips.character = c("34", "34", "34", "34", "34",
"34", "34", "34", "34", "34", "34", "34", "34", "34", "34",
"34", "34", "34", "34", "34", "34"), state.abb = c("NJ",
"NJ", "NJ", "NJ", "NJ", "NJ", "NJ", "NJ", "NJ", "NJ", "NJ",
"NJ", "NJ", "NJ", "NJ", "NJ", "NJ", "NJ", "NJ", "NJ", "NJ"
), tni.per.capita = c(0.0120870785451511, 0.00365800545375359,
0.00841362616734292, 0.0128970859140997, 0.0145481806625452,
0.0167862660255339, 0.00803529522200319, 0.00828772853831489,
0.00395008261562097, 0.00458306196782208, 0.00582151702365076,
0.00525536262729346, 0.00567877891708886, 0.00366375585804471,
0.00720042952241982, 0.00488416303659037, 0.0123907990702893,
0.00559382733314282, 0.00900432777176698, 0.00548943903109783,
0.0124540454273419)), class = "data.frame", row.names = c(NA,
-21L))
county_choropleth(tni_data,
state_zoom = "new jersey",
reference_map = TRUE,
num_colors = 8) +
scale_fill_brewer(palette="YlOrRd") +
labs(title = "DV/SV Incidents by New Jersey County",
legend = "DV/SV Incidents (total)") +
geom_polygon(aes(fill=value), color="black")

