0
我試圖在RSTUDIO的github頁面中給出的例子在小冊子上畫出圈子here.我一直試圖讓它在過去的幾天工作,採用了這裏給出的各種建議以及在其他博客。但我不斷收到以下錯誤:Leaflet Shiny:點數據未找到
Warning: Error in derivePoints: Point data not found; please provide addCircles with data and/or lng/lat arguments
我不確定是否缺少任何庫或者是否有任何包需要更新。以下是隨代碼一起提供的數據集。如果我從r-studio的github頁面運行該示例,它將毫無問題地運行。我檢查數據的結構,並且兩者是完全相同的類型。不知道問題出在哪裏:
期望的輸出:每個類別(穀類,脈衝)的差異大小的圓形的地圖,在選擇時會發生反應性變化。
library(shiny)
library(leaflet)
library(RColorBrewer)
data <- structure(list(LATITUDE = c(26.912434, 28.459497, 23.022505,
10.790483, 28.704059), LONGITUDE = c(75.787271, 77.026638, 72.571362,
78.704673, 77.10249), CEREALS = c(450L, 350L, 877L, 1018L, 600L
), PULSES = c(67L, 130L, 247L, 250L, 324L)), .Names = c("LATITUDE",
"LONGITUDE", "CEREALS", "PULSES"), row.names = c(1263L, 4524L,
10681L, 7165L, 12760L), class = "data.frame")
ui <- bootstrapPage(
tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
leafletOutput("map", width = "100%", height = "100%"),
absolutePanel(top = 10, right = 10,
selectInput(inputId = "productCategoryMonthly", "PRODUCTS",choices = NULL, selected = NULL),
selectInput("colors", "Color Scheme",rownames(subset(brewer.pal.info, category %in% c("seq", "div")))
)))
server <- function(input, output, session) {
df <- reactive({data})
observe({
withProgress(message = "Loading data, Please wait...",value = 0.1, {
updateSelectizeInput(session,inputId = "productCategoryMonthly", choices = as.character(sort(toupper(colnames(df()[,c(3:4)]))),decreasing = TRUE), selected = "CEREALS", server = TRUE)
})
})
filteredData <- reactive({
if(input$productCategoryMonthly == "CEREALS") {
df()[,c(1,2,3)]
} else if (input$productCategoryMonthly == "PULSES") {
df()[,c(1,2,4)]
}
})
output$map <- renderLeaflet({
leaflet(df()) %>% addTiles() %>%
fitBounds(~min(LONGITUDE), ~min(LATITUDE), ~max(LONGITUDE), ~max(LATITUDE))
})
observe({
mag <- filteredData()[[input$productCategoryMonthly]]
leafletProxy("map", data = filteredData()) %>%
clearShapes() %>%
addCircles(radius = ~10^mag/10, weight = 1, color = "#777777",
fillOpacity = 0.7, popup = ~paste(mag)
)
})
}
shinyApp(ui, server)
Beakovic很多很多的感謝...真正體會.....一直在瘋狂去在它過去兩天幾乎....我已經試過幾乎每一個可能的組合.. .including使用的mag值是....仍然無法得到它....我可能從來沒有想過重新調整值的調整....沒有問題,下拉...它的工作原理我的原始版本。非常感謝。 – Apricot