A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://stackoverflow.com/questions/61111024/trouble-using-plot-usmap-function-in-usmap-package below:

r - Trouble using plot_usmap() function in usmap package

I have decided to brush up on my map making skills and am using the publicly available COVID data from: https://www.kaggle.com/sudalairajkumar/covid19-in-usa

Below is my code:

USdata <- us_states_covid19_daily %>%
    group_by(state)%>%
    summarise(values = sum(positive))

#Assign each state its fips code using fips()
USdata$state <- as.numeric(fips(USdata$state))
USdata$values <- as.numeric(USdata$values)

#Rename columns appropriately
names(USdata)[names(USdata) == "state"] <- "fips"
USdata <- na.omit(USdata)

plot_usmap(data = USdata)

I keep receiving this error:

Error in `[.data.frame`(map_df, , values) : undefined columns selected

This is what my data frame looks like:

> head(USdata)
# A tibble: 6 x 2
   fips values
  <dbl>  <dbl>
1     2   1908
2     1  16845
3     5   9084
4     4  21232
5     6 128974
6     8  44905

My data frame could also look like this if I delete a line of code:

> head(USdata)
# A tibble: 6 x 2
  fips  values
  <fct>  <dbl>
1 AK      1908
2 AL     16845
3 AR      9084
4 AZ     21232
5 CA    128974
6 CO     44905

Anyone know what I'm doing wrong?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4