2016-07-30 6 views
1

に、マップに緯度と経度の点を印刷する必要がありマップです。私はそれをやろうとしていましたが、私のオブジェクトを見つけることができないというエラーが表示されますdプロット点(緯度・経度)私は光沢のあるアプリケーションとその一部を作成しようとしているggmap

私はちょうどマップを置く場合

はポイントなしで、良い作品が、それはステップです。

マイserver.Rコードは次のとおりです。私が持っているui.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) 

################################ 
#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ファイル、または少なくとも私はそれを考えていますが、以前のプロット(ヒストグラム、パイ、ボックスプロットなど)は同じシステムで行っていました。

私は、この継続すべきかわかりません。

緯度と経度の列は両方とも数値です。

答えて

0

は、以下の作業にserver.Rを変更していますか?

library(ggmap) 

d <- reactive({ 
    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=".")) 
}) 



output$MapPr <- renderPlot({ 
    df <- d() 
    map <- get_map(location = 'Baltimore', zoom = 12) 
    ggmap(map) + 
     geom_point(aes(as.numeric(Longitude), 
         as.numeric(Latitude)), 
        data = df, alpha =.5, color = "darkred") 
}, width = 800, height = 700) 
+0

今、私は別のものを取得しています。警告:$のエラー: 'closure'タイプのオブジェクトはサブセット化できません – neoSmith

+0

私の悪いです。今すぐ確認していただけますか? 'aes'の中で' $ 'を使うべきではない – Sumedh

+0

うん!それは今動作します:Dロットの感謝の@Sumedh!私はまた、私のCSVファイルへの別のエラーについても気づいた。 – neoSmith

関連する問題