I think it's just a typo — you have a stray comma at the end of layout(geo=list(scope="usa"),), implying that you're supplying another argument to layout. Remove the comma, and all is well:
library(plotly)
mh <- data.frame(
rank = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
43, 44, 45, 46, 47, 48, 49, 50, 51),
state = c("CT", "MA", "VT", "SD", "MN", "NJ", "IA", "ND", "PA", "ME",
"DE", "NY", "AK", "MD", "IL", "HI", "MI", "DC",
"KY", "NH", "KS", "NM", "CA", "OK", "CO", "OH",
"NE", "FL", "WY", "WA", "MO", "TX", "NC", "GA",
"WI", "RI", "SC", "VA", "MT", "UT", "TN", "LA",
"WV", "MS", "IN", "AL", "AR", "ID", "OR", "AZ",
"NV")
)
plot_ly(
type = "choropleth",
locations = mh$state,
locationmode = "USA-states",
z = mh$rank
) %>%
layout(geo = list(scope = "usa"))