有人在Code Workbook中使用r-Leaflet创建了一个leaflet地图吗?我有一个运行正常的脚本(也是在R中双重检查),但是我如何让它可视化,然后在报告中使用等。我尝试了各种调整,可以让它运行,但没有成功-任何想法
leaflet_map <- function(map_data) {
library(leaflet)
data<-map_data
# first cut the continuous variable into bins
# these bins are now factors
data$Fill_rateLvl <- cut(data$Fill_rate,
c(0,.5,0.6,0.7,0.8,0.9,1), include.lowest = T,
labels = c('<50%', '50-60%', '60-70%', '70-80%', '80-90%','90-100%'))
# then assign a palette to this using colorFactor
# in this case it goes from red for the smaller values to yellow and green
# standard stoplight for bad, good, and best
FillCol <- colorFactor(palette = 'RdYlGn', data$Fill_rateLvl)
m<-leaflet() %>%
addTiles() %>%
addProviderTiles(providers$CartoDB.Positron)%>%
setView(lng = -0, lat = 50, zoom = 8) %>%
addCircleMarkers(data = data, lat = ~lat, lng = ~long,
color = ~FillCol(Fill_rateLvl), popup = data$Lead_employer,
radius = ~sqrt(Fill_rate*50), group = 'Fill rate') %>%
addLegend('bottomright', pal = FillCol, values = data$Fill_rateLvl,
title = 'Fill rate for next two weeks',
opacity = 1)
return(NULL)
}发布于 2021-06-21 15:33:14
我不熟悉代码工作簿中的R,但在我看来,您需要将您的传单地图物化为数据集,然后在某种地图兼容的UI中使用它。
例如,slate有一个有传单支持的地图小部件。您可以在yourfoundrystackhere.com/workspace/documentation/product/slate/map-widget中找到相关的文档和示例
https://stackoverflow.com/questions/67999372
复制相似问题