我尝试使用以下代码绘制图表:
library(leaflet.minicharts)
library(leaflet)
data("eco2mix")
head(eco2mix)
View(eco2mix)
library(dplyr)
prod2016 <- eco2mix %>%
mutate(renewable = bioenergy + solar + wind + hydraulic,
non_renewable = total - bioenergy - solar - wind - hydraulic) %>%
filter(grepl("2016", month) & area != "France") %>%
select(-month) %>%
group_by(area, lat, lng) %>%
summarise_all(sum) %>%
ungroup()
tilesURL <- "http://server.arcgisonline.com/ArcGIS/rest/services/Canvas /World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}"
basemap <- leaflet(width = "100%", height = "400px") %>%
addTiles(tilesURL)
colors <- c("#4fc13c", "#cccccc")
basemap %>%
addMinicharts(
prod2016$lng, prod2016$lat,
type = "pie",
chartdata = prod2016[, c("renewable", "non_renewable")],
colorPalette = colors,
width = 60 * sqrt(prod2016$total)/
sqrt(max(prod2016$total)),
transitionTime = 0)
但是我收到了一个错误:
addMinicharts中的错误(。,prod2016 $ lng,prod2016 $ lat,type =&#34; pie&#34;,
chartdata = prod2016 [,:未使用的参数(chartdata = prod2016 [,c(&#34;可再生&#34;,&#34; non_renewable&#34;)])
答案 0 :(得分:0)
R版本3.4.0(2017-04-21) 平台:x86_64-w64-mingw32 / x64(64位) 运行于:Windows&gt; = 8 x64(build 9200)
Matrix产品:默认
区域设置: [1] LC_COLLATE = English_United Kingdom.1252 LC_CTYPE = English_United Kingdom.1252 LC_MONETARY = English_United Kingdom.1252 [4] LC_NUMERIC = C LC_TIME = English_United Kingdom.1252
附加基础包: [1] stats graphics grDevices utils数据集方法库
其他附件包:
[1] leaflet_1.1.0 dplyr_0.5.0 leaflet.minicharts_0.1.0 sp_1.2-4
[5] RevoUtilsMath_10.0.0
通过命名空间加载(而不是附加):
[1] Rcpp_0.12.10 lattice_0.20-35 assertthat_0.2.0 digest_0.6.12 mime_0.5 grid_3.4.0 R6_2.2.0
[8] jsonlite_1.4 DBI_0.6-1 xtable_1.8-2 magrittr_1.5 lazyeval_0.2.0 RevoUtils_10.0.4 tools_3.4.0
[15] htmlwidgets_0.8 crosstalk_1.0.0 shiny_1.0.3 yaml_2.1.14 httpuv_1.3.3 compiler_3.4.0 htmltools_0.3.6
[22] tibble_1.3.0