usmap by county

Hi. Why does the following not work, despite being one of the vignettes?

2. Mapping the US

library(usmap)
library(ggplot2)

df <- data.frame(
fips = c("10001", "10003", "10005"),
values = c(93, 98, 41)
)
plot_usmap(data = df)

Error in [.data.frame(map_df, , values) : undefined columns selected
Calls: ... scales_add_defaults -> lapply -> FUN -> [ -> [.data.frame
Execution halted

2. Mapping the US

I did a copy-and-paste of your code and it worked for me! Are you sure you have the packages installed correctly? Start from a clean R session?

Stephen

> library(usmap)
> library(ggplot2)
> 
> df <- data.frame(
+     fips = c("10001", "10003", "10005"),
+     values = c(93, 98, 41)
+ )
> plot_usmap(data = df)
> 
>

I did start from a clean R session. No error after line one:

library(usmap)
library(ggplot2)
df <- data.frame(

  • fips = c("10001", "10003", "10005"),
  • values = c(93, 98, 41)
  • )

plot_usmap(data = df)
Error in [.data.frame(map_df, , values) : undefined columns selected

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.