Black Lives Matter. Please consider donating to Black Girls Code today.

County level Choropleth Map using Plotly R - Unable to generate map

Hi there,
I tried to recreate the choropleth map on my local machine as suggested here https://plotly.com/r/choropleth-maps/. The map never loads and my CPU just goes to 100% utilization (R studio session) plus my computer hangs. Interestingly, no error messages or warnings too. Does anyone else face the same problem?

library(plotly)
library(rjson)

url <- 'https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json'
counties <- rjson::fromJSON(file=url)
url2<- "https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv"
df <- read.csv(url2, colClasses=c(fips="character"))
g <- list(
  scope = 'usa',
  projection = list(type = 'albers usa'),
  showlakes = TRUE,
  lakecolor = toRGB('white')
)
fig <- plot_ly()
fig <- fig %>% add_trace(
    type="choropleth",
    geojson=counties,
    locations=df$fips,
    z=df$unemp,
    colorscale="Viridis",
    zmin=0,
    zmax=12,
    marker=list(line=list(
      width=0)
    )
  )
fig <- fig %>% colorbar(title = "Unemployment Rate (%)")
fig <- fig %>% layout(
    title = "2016 US Unemployment by County"
)

fig <- fig %>% layout(
    geo = g
  )

fig

Is this because it is too much to load?

Future work:

Ultimately, I am trying to build a US-County level Choropleth map using plotly and R, where the color is based on “Some value” from my own Dataframe (see below for columns)

FIPS | Some value | …other unrelated columns

If suppose the above code can be made to work, can someone suggest what modification should I do to create a choropleth using my dataframe above? For more context: my eventual plan is to render the Plotly map on R-Shiny (I have that framework figured out mostly)