library(plotly)
xdf <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/2014_us_cities.csv")
xdf$q <- with(xdf, cut(pop, quantile(pop)))
levels(xdf$q) <- paste(c("1st", "2nd", "3rd", "4th", "5th"), "Quantile")
xdf$q <- as.ordered(xdf$q)
list(
scope = "usa",
projection = list(
type = "albers usa"
),
showland = TRUE,
landcolor = toRGB("gray85"),
subunitwidth = 1,
countrywidth = 1,
subunitcolor = toRGB("white"),
countrycolor = toRGB("white")
) -> g
plot_geo(
data = xdf,
locationmode = "USA-states",
sizes = c(1, 250)
) %>%
add_markers(
x = ~ lon, y = ~ lat,
size = ~ pop, color = ~ q,
hoverinfo = "text",
text = ~ paste(xdf$name, "<br />", xdf$pop / 1e6, " million")
) %>%
layout(
title = "2014 US city populations<br>(Click legend to toggle)",
geo = g
) -> p
p
这是错误
Warning messages:1: `line.width` does not currently support multiple values. 2: `line.width` does not currently support multiple values. 3: `line.width` does not currently support multiple values. 4: `line.width` does not currently support multiple values.
我如何处理警告以显示地图?该图仅显示图例,但地图不可见。
以下是会话信息
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
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] bindrcpp_0.2.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 pillar_1.3.0 compiler_3.5.1 later_0.7.5
[5] plyr_1.8.4 bindr_0.1.1 tools_3.5.1 digest_0.6.18
[9] jsonlite_1.5 tibble_1.4.2 gtable_0.2.0 viridisLite_0.3.0
[13] pkgconfig_2.0.2 rlang_0.3.0.1 shiny_1.2.0 rstudioapi_0.8
[17] crosstalk_1.0.0 yaml_2.2.0 dplyr_0.7.8 httr_1.3.1
[21] htmlwidgets_1.3 grid_3.5.1 tidyselect_0.2.5 glue_1.3.0
[25] data.table_1.11.8 R6_2.3.0 plotly_4.8.0 ggplot2_3.1.0
[29] purrr_0.2.5 tidyr_0.8.2 magrittr_1.5 scales_1.0.0
[33] promises_1.0.1 htmltools_0.3.6 assertthat_0.2.0 xtable_1.8-3
[37] mime_0.6 colorspace_1.3-2 httpuv_1.4.5 lazyeval_0.2.1
[41] munsell_0.5.0 crayon_1.3.4
我不确定如果对其他人有用,可能是什么问题。我已经包括了sessionInfo以及后续的评论的后续内容。