2017-05-09 41 views
0

我有兩組數據,我試圖用rshiny轉換爲geomaps。我已經能夠獲得我的位置的座標,並且能夠將它們映射到R.我現在開始爲Shiny編寫代碼塊。Geomapping Data in Shiny

樣本數據:

| X1 | Location   | Longitude | Latitude | 
1 | 1 | Brooklyn, NY, USA | 40.678178 | -73.9441579 | 
2 | 2 | Liverpool, UK  | 53.408371 | -2.9915726 | 

我的UI返回我的標題和選擇框,但不管是什麼我把我的服務器,我沒有得到我的地圖別的。有誰知道我應該運行什麼代碼行來獲得我的座標CSV到我的閃亮應用程序?或者,如果我只是將我的輸出轉換爲我的地圖的圖像,而不是?

這裏是我一直使用至今代碼:

library (shiny) 
library (leaflet) 
ui <- fluidPage(
titlePanel("Sentiments of #Breastfeeding Reactions") , 
    selectInput("var", 
       label = "Choose a sentiment to display", 
       choices = list("Positive", "Negative"), 
       selected = "Positive") 
    leafletOutput("PositiveMap") 
server <- function(input, output) 
shinyApp(ui = ui, server = server) 

我想與之合作的數據幀是「A.CSV」爲積極的情緒和「B.CSV」負情緒。我看過閃亮的教程,但仍然不確定如何繪製數據。 `

+0

你可以添加你到目前爲止嘗試過的任何代碼嗎?例如,你打電話給哪個地圖功能?你有哪些長/拉特的範圍? – timfaber

回答

0

有關具體的幫助,您需要共享您的服務器代碼。然而,下面是它應該(看起來)的基本問題:

output$PositiveMap <- renderLeaflet({ 
leaflet() %>% setView(lat=37.68,lng=-97.33,zoom=4) %>% 
addTiles() %>% addMarkers(lng = A$Longitude, lat =A$Latitude) 
)}