2017-10-17 99 views
0

我極力把下面的代碼的圖形:圖形繪製錯誤

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) 

但我得到一個錯誤:

Error in addMinicharts(., prod2016$lng, prod2016$lat, type = "pie",
chartdata = prod2016[,: unused argument (chartdata = prod2016[,c("renewable", "non_renewable")])

+0

它適合我。什麼是你的sessionInfo()? – MLavoie

+0

我已經發布了我的會話作爲答案,字符太多:-) –

+0

您可以更新您的dplyr和leaflet.minicharts並重新運行您的代碼。 – MLavoie

回答

0

[R版本3.4.0( 2017年4月21日) 平臺:x86_64的-W64-的mingw32/64(64位) 下運行:視窗> = 8 64(建立9200)

矩陣產品:默認

區域設置: [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]統計圖形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

+0

只需將此信息添加到您的問題中即可。你可以編輯你的問題。這個空間只是爲了回答。 – MLavoie