Leaflet and Shiny “could not find function leafletOutput()”2019 Community Moderator ElectionGrouping functions (tapply, by, aggregate) and the *apply familyR Leaflet (CRAN) - how to register clicking off a markerSave leaflet map in ShinyHow to get Leaflet for R use 100% of Shiny dashboard heightAdd coordinates to image for use as map in Leaflet, Shiny and Shinydashboard packages in RR Shiny reactive subsetting of data in a leaflet plotLeaflet Shiny Integration slowAdd “rgb” legend to R leaflet heatmapOptimising Shiny + Leaflet performance for detailed maps with many 'layers'Shiny dashboard and leaflet using selectInput

Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?

Is it insecure to send a password in a `curl` command?

Bach's Toccata and Fugue in D minor breaks the "no parallel octaves" rule?

Are all passive ability checks floors for active ability checks?

What is a ^ b and (a & b) << 1?

Print a physical multiplication table

Fastest way to pop N items from a large dict

Why do tuner card drivers fail to build after kernel update to 4.4.0-143-generic?

As a new Ubuntu desktop 18.04 LTS user, do I need to use ufw for a firewall or is iptables sufficient?

What is the relationship between relativity and the Doppler effect?

Is "upgrade" the right word to use in this context?

What is "focus distance lower/upper" and how is it different from depth of field?

Bacteria contamination inside a thermos bottle

What options are left, if Britain cannot decide?

Is it normal that my co-workers at a fitness company criticize my food choices?

Book about superhumans hiding among normal humans

What is the purpose or proof behind chain rule?

ERC721: How to get the owned tokens of an address

Could the Saturn V actually have launched astronauts around Venus?

Why do newer 737s use two different styles of split winglets?

PTIJ: Who should I vote for? (21st Knesset Edition)

My adviser wants to be the first author

How to terminate ping <dest> &

Welcoming 2019 Pi day: How to draw the letter π?



Leaflet and Shiny “could not find function leafletOutput()”



2019 Community Moderator ElectionGrouping functions (tapply, by, aggregate) and the *apply familyR Leaflet (CRAN) - how to register clicking off a markerSave leaflet map in ShinyHow to get Leaflet for R use 100% of Shiny dashboard heightAdd coordinates to image for use as map in Leaflet, Shiny and Shinydashboard packages in RR Shiny reactive subsetting of data in a leaflet plotLeaflet Shiny Integration slowAdd “rgb” legend to R leaflet heatmapOptimising Shiny + Leaflet performance for detailed maps with many 'layers'Shiny dashboard and leaflet using selectInput










1















I have a leaflet map and I want the option of switching from the values of A being mapped to the values of B. Every example I can find says to use shiny and leaflet and all of these examples include something along the lines of:



ui <- fluidPage(
selectInput(inputId = "Data",
label = "Data",
choices = c("A","B"),
leafletProxy(outputId = "map") #or leafletOutput
))


but I keep getting the error that




leafletProxy (or leafletOutput)does not exist




. How do I solve this? My leaflet is created with :



mypal <- colorNumeric(palette = "viridis", domain = d$A)

leaflet() %>%
addProviderTiles("OpenStreetMap.Mapnik") %>%
setView(lat = 39.8283, lng = -98.5795, zoom = 4) %>%
addPolygons(data =

USA, stroke = TRUE, color='black', opacity=1, weight=.5, smoothFactor = 0.2, fillOpacity = 1,
fillColor = ~mypal(d$A),
popup = paste('<b>',d$state, "</b><br>A:", d$A) %>%
addLegend(position = "bottomleft", pal = mypal, values = d$A,
title = "A",
opacity = 1)









share|improve this question




























    1















    I have a leaflet map and I want the option of switching from the values of A being mapped to the values of B. Every example I can find says to use shiny and leaflet and all of these examples include something along the lines of:



    ui <- fluidPage(
    selectInput(inputId = "Data",
    label = "Data",
    choices = c("A","B"),
    leafletProxy(outputId = "map") #or leafletOutput
    ))


    but I keep getting the error that




    leafletProxy (or leafletOutput)does not exist




    . How do I solve this? My leaflet is created with :



    mypal <- colorNumeric(palette = "viridis", domain = d$A)

    leaflet() %>%
    addProviderTiles("OpenStreetMap.Mapnik") %>%
    setView(lat = 39.8283, lng = -98.5795, zoom = 4) %>%
    addPolygons(data =

    USA, stroke = TRUE, color='black', opacity=1, weight=.5, smoothFactor = 0.2, fillOpacity = 1,
    fillColor = ~mypal(d$A),
    popup = paste('<b>',d$state, "</b><br>A:", d$A) %>%
    addLegend(position = "bottomleft", pal = mypal, values = d$A,
    title = "A",
    opacity = 1)









    share|improve this question


























      1












      1








      1








      I have a leaflet map and I want the option of switching from the values of A being mapped to the values of B. Every example I can find says to use shiny and leaflet and all of these examples include something along the lines of:



      ui <- fluidPage(
      selectInput(inputId = "Data",
      label = "Data",
      choices = c("A","B"),
      leafletProxy(outputId = "map") #or leafletOutput
      ))


      but I keep getting the error that




      leafletProxy (or leafletOutput)does not exist




      . How do I solve this? My leaflet is created with :



      mypal <- colorNumeric(palette = "viridis", domain = d$A)

      leaflet() %>%
      addProviderTiles("OpenStreetMap.Mapnik") %>%
      setView(lat = 39.8283, lng = -98.5795, zoom = 4) %>%
      addPolygons(data =

      USA, stroke = TRUE, color='black', opacity=1, weight=.5, smoothFactor = 0.2, fillOpacity = 1,
      fillColor = ~mypal(d$A),
      popup = paste('<b>',d$state, "</b><br>A:", d$A) %>%
      addLegend(position = "bottomleft", pal = mypal, values = d$A,
      title = "A",
      opacity = 1)









      share|improve this question
















      I have a leaflet map and I want the option of switching from the values of A being mapped to the values of B. Every example I can find says to use shiny and leaflet and all of these examples include something along the lines of:



      ui <- fluidPage(
      selectInput(inputId = "Data",
      label = "Data",
      choices = c("A","B"),
      leafletProxy(outputId = "map") #or leafletOutput
      ))


      but I keep getting the error that




      leafletProxy (or leafletOutput)does not exist




      . How do I solve this? My leaflet is created with :



      mypal <- colorNumeric(palette = "viridis", domain = d$A)

      leaflet() %>%
      addProviderTiles("OpenStreetMap.Mapnik") %>%
      setView(lat = 39.8283, lng = -98.5795, zoom = 4) %>%
      addPolygons(data =

      USA, stroke = TRUE, color='black', opacity=1, weight=.5, smoothFactor = 0.2, fillOpacity = 1,
      fillColor = ~mypal(d$A),
      popup = paste('<b>',d$state, "</b><br>A:", d$A) %>%
      addLegend(position = "bottomleft", pal = mypal, values = d$A,
      title = "A",
      opacity = 1)






      r shiny leaflet shinydashboard






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 6 at 21:00







      John Smith

















      asked Mar 6 at 20:52









      John SmithJohn Smith

      114




      114






















          1 Answer
          1






          active

          oldest

          votes


















          0














          It seems from your example that your shiny has not server function, so it is not going to work.



          Please, find attache a mock shiny you can start building on:



          library(shiny)
          library(leaflet)



          ui <- fluidPage(
          selectInput(inputId = "Data",
          label = "Data",
          choices = c("A","B")),
          leafletOutput("map")
          )

          server <- server <- function(input, output, session) {

          output$map=renderLeaflet(
          if((input$Data) == "A")
          point = c(42.6525, -73.757222)

          if((input$Data) == "B")
          point = c(39.283333, -76.616667)



          leaflet() %>%
          addProviderTiles("OpenStreetMap.Mapnik") %>%
          addMarkers(lat=point[1], lng=point[2])
          )


          It will show "Albany" when you select "A" and Baltimore when you select "B"



          Basically:



          ui is kind of the "interface", what it is going to be shown:



          1. selectInput: you can choose A or B here


          2. leafletOutput: will show the leaflet map


          server will do the "hard job" of creating the map and computing actions when you use selecInput:



          output$map means that we want to paint the leafletOuput (that is why it is call map, as in leafletOutput("map")



          Then, according to the input selected (A or B)



           if((input$Data) == "A")
          point = c(42.6525, -73.757222)

          if((input$Data) == "B")
          point = c(39.283333, -76.616667)



          We assign coordinates of Albany or Baltimore to point.
          Finally, we build the map:



          leaflet() %>% 
          addProviderTiles("OpenStreetMap.Mapnik") %>%
          addMarkers(lat=point[1], lng=point[2])


          PLEASE, take into account that this is a mock shiny, it is far from perfect, it is only illustrative.



          Best!






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031938%2fleaflet-and-shiny-could-not-find-function-leafletoutput%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            It seems from your example that your shiny has not server function, so it is not going to work.



            Please, find attache a mock shiny you can start building on:



            library(shiny)
            library(leaflet)



            ui <- fluidPage(
            selectInput(inputId = "Data",
            label = "Data",
            choices = c("A","B")),
            leafletOutput("map")
            )

            server <- server <- function(input, output, session) {

            output$map=renderLeaflet(
            if((input$Data) == "A")
            point = c(42.6525, -73.757222)

            if((input$Data) == "B")
            point = c(39.283333, -76.616667)



            leaflet() %>%
            addProviderTiles("OpenStreetMap.Mapnik") %>%
            addMarkers(lat=point[1], lng=point[2])
            )


            It will show "Albany" when you select "A" and Baltimore when you select "B"



            Basically:



            ui is kind of the "interface", what it is going to be shown:



            1. selectInput: you can choose A or B here


            2. leafletOutput: will show the leaflet map


            server will do the "hard job" of creating the map and computing actions when you use selecInput:



            output$map means that we want to paint the leafletOuput (that is why it is call map, as in leafletOutput("map")



            Then, according to the input selected (A or B)



             if((input$Data) == "A")
            point = c(42.6525, -73.757222)

            if((input$Data) == "B")
            point = c(39.283333, -76.616667)



            We assign coordinates of Albany or Baltimore to point.
            Finally, we build the map:



            leaflet() %>% 
            addProviderTiles("OpenStreetMap.Mapnik") %>%
            addMarkers(lat=point[1], lng=point[2])


            PLEASE, take into account that this is a mock shiny, it is far from perfect, it is only illustrative.



            Best!






            share|improve this answer





























              0














              It seems from your example that your shiny has not server function, so it is not going to work.



              Please, find attache a mock shiny you can start building on:



              library(shiny)
              library(leaflet)



              ui <- fluidPage(
              selectInput(inputId = "Data",
              label = "Data",
              choices = c("A","B")),
              leafletOutput("map")
              )

              server <- server <- function(input, output, session) {

              output$map=renderLeaflet(
              if((input$Data) == "A")
              point = c(42.6525, -73.757222)

              if((input$Data) == "B")
              point = c(39.283333, -76.616667)



              leaflet() %>%
              addProviderTiles("OpenStreetMap.Mapnik") %>%
              addMarkers(lat=point[1], lng=point[2])
              )


              It will show "Albany" when you select "A" and Baltimore when you select "B"



              Basically:



              ui is kind of the "interface", what it is going to be shown:



              1. selectInput: you can choose A or B here


              2. leafletOutput: will show the leaflet map


              server will do the "hard job" of creating the map and computing actions when you use selecInput:



              output$map means that we want to paint the leafletOuput (that is why it is call map, as in leafletOutput("map")



              Then, according to the input selected (A or B)



               if((input$Data) == "A")
              point = c(42.6525, -73.757222)

              if((input$Data) == "B")
              point = c(39.283333, -76.616667)



              We assign coordinates of Albany or Baltimore to point.
              Finally, we build the map:



              leaflet() %>% 
              addProviderTiles("OpenStreetMap.Mapnik") %>%
              addMarkers(lat=point[1], lng=point[2])


              PLEASE, take into account that this is a mock shiny, it is far from perfect, it is only illustrative.



              Best!






              share|improve this answer



























                0












                0








                0







                It seems from your example that your shiny has not server function, so it is not going to work.



                Please, find attache a mock shiny you can start building on:



                library(shiny)
                library(leaflet)



                ui <- fluidPage(
                selectInput(inputId = "Data",
                label = "Data",
                choices = c("A","B")),
                leafletOutput("map")
                )

                server <- server <- function(input, output, session) {

                output$map=renderLeaflet(
                if((input$Data) == "A")
                point = c(42.6525, -73.757222)

                if((input$Data) == "B")
                point = c(39.283333, -76.616667)



                leaflet() %>%
                addProviderTiles("OpenStreetMap.Mapnik") %>%
                addMarkers(lat=point[1], lng=point[2])
                )


                It will show "Albany" when you select "A" and Baltimore when you select "B"



                Basically:



                ui is kind of the "interface", what it is going to be shown:



                1. selectInput: you can choose A or B here


                2. leafletOutput: will show the leaflet map


                server will do the "hard job" of creating the map and computing actions when you use selecInput:



                output$map means that we want to paint the leafletOuput (that is why it is call map, as in leafletOutput("map")



                Then, according to the input selected (A or B)



                 if((input$Data) == "A")
                point = c(42.6525, -73.757222)

                if((input$Data) == "B")
                point = c(39.283333, -76.616667)



                We assign coordinates of Albany or Baltimore to point.
                Finally, we build the map:



                leaflet() %>% 
                addProviderTiles("OpenStreetMap.Mapnik") %>%
                addMarkers(lat=point[1], lng=point[2])


                PLEASE, take into account that this is a mock shiny, it is far from perfect, it is only illustrative.



                Best!






                share|improve this answer















                It seems from your example that your shiny has not server function, so it is not going to work.



                Please, find attache a mock shiny you can start building on:



                library(shiny)
                library(leaflet)



                ui <- fluidPage(
                selectInput(inputId = "Data",
                label = "Data",
                choices = c("A","B")),
                leafletOutput("map")
                )

                server <- server <- function(input, output, session) {

                output$map=renderLeaflet(
                if((input$Data) == "A")
                point = c(42.6525, -73.757222)

                if((input$Data) == "B")
                point = c(39.283333, -76.616667)



                leaflet() %>%
                addProviderTiles("OpenStreetMap.Mapnik") %>%
                addMarkers(lat=point[1], lng=point[2])
                )


                It will show "Albany" when you select "A" and Baltimore when you select "B"



                Basically:



                ui is kind of the "interface", what it is going to be shown:



                1. selectInput: you can choose A or B here


                2. leafletOutput: will show the leaflet map


                server will do the "hard job" of creating the map and computing actions when you use selecInput:



                output$map means that we want to paint the leafletOuput (that is why it is call map, as in leafletOutput("map")



                Then, according to the input selected (A or B)



                 if((input$Data) == "A")
                point = c(42.6525, -73.757222)

                if((input$Data) == "B")
                point = c(39.283333, -76.616667)



                We assign coordinates of Albany or Baltimore to point.
                Finally, we build the map:



                leaflet() %>% 
                addProviderTiles("OpenStreetMap.Mapnik") %>%
                addMarkers(lat=point[1], lng=point[2])


                PLEASE, take into account that this is a mock shiny, it is far from perfect, it is only illustrative.



                Best!







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 6 at 21:15

























                answered Mar 6 at 21:10









                LocoGrisLocoGris

                1,837723




                1,837723





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031938%2fleaflet-and-shiny-could-not-find-function-leafletoutput%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved