I am going to generate a map, find a sample code at following website:
http://www.briansarnacki.com/an-easy-way-to-map-data-in-r-with-plotly/
Here is the code:
library(plotly)
mh<- read.csv("mentalhealth.csv",header=T,sep=',')
plot_ly(type="choropleth", locations=mh$state,
locationmode="USA-states", z=mh$rank) %>%
layout(geo=list(scope="usa"),)
When running the code, I got error message:
Error in layout.plotly(., geo = list(scope = "usa"), ) :
argument is missing, with no default
What is wrong with it? Thank you.
By the way, paste the data here:
rank state
1 CT
2 MA
3 VT
4 SD
5 MN
6 NJ
7 IA
8 ND
9 PA
10 ME
11 DE
12 NY
13 AK
14 MD
15 IL
16 HI
17 MI
18 DC
19 KY
20 NH
21 KS
22 NM
23 CA
24 OK
25 CO
26 OH
27 NE
28 FL
29 WY
30 WA
31 MO
32 TX
33 NC
34 GA
35 WI
36 RI
37 SC
38 VA
39 MT
40 UT
41 TN
42 LA
43 WV
44 MS
45 IN
46 AL
47 AR
48 ID
49 OR
50 AZ
51 NV