1
我想做一個閃亮的應用程序和它的一部分,是一個地圖,應該打印經緯度點到地圖。我一直在努力去做,但我得到一個錯誤,告訴我它找不到我的對象d
。繪製點(緯度和經度)到ggmap
如果我只是把地圖工程好,沒有點,但它是一個步驟。
我server.R代碼:
#Reactive Map
output$MapPr <- renderPlot({
d <- switch(input$chDatabase,
"BPD 2013 Baltimore" = read.csv("./Data/BPD_13_Bal.csv",
header=TRUE, sep=",", dec="."),
"BPD 2014 Baltimore" = read.csv("./Data/BPD_14_Bal.csv",
header=TRUE, sep=",", dec=".")
)
library(ggmap)
map <- get_map(location = 'Baltimore', zoom = 12)
ggmap(map)
ggmap(map) +
geom_point(aes(as.numeric(d$Longitude), as.numeric(d$Latitude)), data = d, alpha =.5, color = "darkred")
}, width = 800, height = 700)
在ui.R我有:
################################
#2nd tabpanel for Reactive Map
tabPanel("Reactive Map",
#SideBarLayout for sidebar Panel for the options of the map
sidebarLayout(
#SideBar Panel with options to adjust the map
sidebarPanel(
#Databases selection
selectInput("chDatabaseMap","Choose DataBase:",
choices = c("BPD 2013 Baltimore", "BPD 2014 Baltimore"))
),
###################################
#Main panel to put plots
mainPanel(
plotOutput("MapPr")
)
)
)
順便說一句,我已經看到了與負荷問題csv文件,或者至少我認爲,但是我已經用同一個系統做的以前的圖(直方圖,餅圖,箱形圖等),它們工作。
我不知道該如何繼續。
緯度和經度的列都是數字。
現在我得到另一個;警告:類型'closure'的$:object中的錯誤不是子集合 – neoSmith
我的錯誤。你可以請現在檢查嗎?不應該在'aes'內使用'$' – Sumedh
是啊!它現在有效:D感謝@Sumedh!我也意識到另一個錯誤到我的CSV文件。 – neoSmith