Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205491

in R, leaflet don't reflect the latitude nor longitude?

$
0
0

in an attempt to create map like this one with my data frame and filters I found leaflet doesn't reflect any of the long. or lat. accordingly no pop up to show.dataset& css

the code

library(shiny)
library(dplyr)
library(leaflet)
library(readxl)
CBdata <- read_excel("cblnglt.xlsx")
df0<- data.frame("cho"=c("No schooling completed","vocational","Bachelor","Post Graduate ","Single","Married","Divorced","others","male","female","under_20","21_30","31_39","31_40","41_50","51_59","over_60","Retired","Public_Employee","Private_Employee","Self_employeed","Unemployed","Others"),
               "cat"=c("educ.","educ.","educ.","educ.","Relationship.Status","Relationship.Status","Relationship.Status","Relationship.Status","by_gender","by_gender","By_age","By_age","By_age","By_age","By_age","By_age","By_age","profession","profession","profession","profession","profession","profession"))


ui<-
  navbarPage("Mapping Dashboard",
             theme = "bootstrap.css",
             tabPanel("tbd",
                      div(class="outer",
                          leafletOutput("mymap", width = "100%", height = "100%"), #
                          absolutePanel(id = "controls", class = "panel panel-default", 
                                        fixed = TRUE,draggable = TRUE, top = "10%", left = "auto", right = 20, bottom = "auto",
                                        width = 330, height = "auto", cursor = "move",br(),
                                        selectInput("region", "Which governorate?", unique(CBdata$by_gov), selected = "Cairo"),
                                        selectInput("variable", "Filter by?", unique(df0$cat),         selected = "by_gender"),
                                        selectInput("sndvariable","sub filter",choices =NULL),
                                        selectInput("indicator","select Indicator",c("total_customers","total_revenus"),
                                                    selected = "total_customers"),
                                        plotOutput("bar", height = "250px"),
                          ))),
             tabPanel("By Product"))

server<-function(input,output,session){
  observe({
    TX<-dp%>%filter(cat==input$variable)%>%select(cho)
    updateSelectInput(session,"sndvariable","sub filter",choices = unique(TX))
  })
  CBD1<-reactive({
    CBdata%>%
      group_by(lng,lat,input$variable,by_gov)%>%
      filter(input$variable==input$sndvariable,by_gov==input$region)%>%
      summarize(summation=sum(get(input$indicator)))
  })
  output$mymap<-renderLeaflet({
    CBD1()%>%leaflet()%>%
      addProviderTiles(provider = "CartoDB.DarkMatter")%>%
      addCircleMarkers(lng=lng,lat=lat)
  })

    }

shinyApp(ui,server)

attahced the css that i used in my app, and all data required. if i removed the lng=~lng and inserted the real value it works fine but the issue arise when we use the dataframe.

thanks in advance


Viewing all articles
Browse latest Browse all 205491

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>