Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R Plotly choropleth映射空白_R_Plotly - Fatal编程技术网

R Plotly choropleth映射空白

R Plotly choropleth映射空白,r,plotly,R,Plotly,这是 我试图在R中制作一个Plotly choropleth贴图。我将Plotly示例页面中的代码镜像如下: wvs_ag = read.csv("wvs_ag.csv") l = list(color = toRGB("grey"), width = 0.5) g = list( showframe = FALSE, showcoastlines = FALSE, showland = TRUE, projection = list(type = 'Mercator') )

这是

我试图在R中制作一个Plotly choropleth贴图。我将Plotly示例页面中的代码镜像如下:

wvs_ag = read.csv("wvs_ag.csv")

l = list(color = toRGB("grey"), width = 0.5)

g = list(
  showframe = FALSE,
  showcoastlines = FALSE,
  showland = TRUE,
  projection = list(type = 'Mercator')
)

p = plot_geo(wvs_ag) %>%
  add_trace(
    z = ~Agree_w, color = ~Agree_w, colors = 'Blues',
    text = ~Country_Code.p, locations = ~Country_Code.p, marker = list(line = l)) %>%
  colorbar(title = 'Agree_w') %>%
  layout(
    title = 'Title',
    geo = g
  )
但是,这会为我生成一张空白地图,只有比例在右侧可见。如何使地图显示

(旁注:我不知道Plotly接受的确切国家代码。我的原始数据有一组国家代码,所以我只是将其与Plotly示例页面中的数据合并,并使用它们的县代码。)

编辑:以下是sessioninfo()输出:


您在'read.csv'和dropbox帐户中的文件名不匹配。但除此之外,代码产生了一个很好的结果:啊,对不起。刚刚修复了read.csv输入错误。嗯,奇怪的是,当运行相同的代码时,你能生成一个地图而我却不能。我不知道这是为什么。我注意到,有时当R-Studio plot viewer必须在不同类型的输出之间来回切换时,它有时会“卡住”,只显示一个空白屏幕。可能是R-Studio bug,也可能是htmlwidget bug。也许这就是,或者与之相关。下次发生这种情况时,我会更加注意,并尝试找到一个复制。同样,在这种情况下,如果您没有得到结果,而其他人却得到了结果,那么您应该将
sessionInfo()
结果附加到您的问题中。
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] sp_1.2-4

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.10      lattice_0.20-35   tidyr_0.6.1       viridisLite_0.2.0 digest_0.6.12    
 [6] dplyr_0.5.0       assertthat_0.1    grid_3.3.3        plyr_1.8.4        R6_2.2.0         
[11] jsonlite_1.3      gtable_0.2.0      DBI_0.6-1         magrittr_1.5      scales_0.4.1     
[16] httr_1.2.1        ggplot2_2.2.1     lazyeval_0.2.0    tools_3.3.3       htmlwidgets_0.8  
[21] purrr_0.2.2       munsell_0.4.3     yaml_2.1.14       base64enc_0.1-3   colorspace_1.3-2 
[26] htmltools_0.3.5   plotly_4.5.6      tibble_1.3.0