【发布时间】:2023-04-02 11:30:02
【问题描述】:
我正在尝试制作一个闪亮的应用程序,它的一部分是一张应该将纬度和经度点打印到地图中的地图。我一直在尝试这样做,但我收到一条错误消息,告诉我它找不到我的对象 d。
如果我只是把地图效果很好,没有积分但这是一个步骤。
我的 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 文件的加载问题,或者至少我认为是这样,但是我一直在使用之前的图(直方图、饼图、箱线图等)相同的系统,它们可以工作。
我不知道该如何继续。
纬度和经度列都是数字。
【问题讨论】:
标签: r shiny coordinates ggmap