library(shiny) library(leaflet) library(nycflights13) library(dt) parguera <- nycflights13::flights r_colors <- rgb(t(col2rgb(colors()) / 255)) names(r_colors) <- colors() ui <- fluidpage( titlepanel("noaa caribbean coral data"), leafletoutput("mymap"), p(), actionbutton("laparguera", "la parguera data"), actionbutton("mona", "mona island data"), actionbutton("isla", "isla catalina data") ) server <- function(input, output, session) { output$mymap <- renderleaflet({ leaflet() %>% addtiles() %>% addmarkers(lat = 17.95, lng = - 67.05, popup = "la parguera ") %>% addmarkers(lat = 18.00, lng = -67.50, popup = "mona island") %>% addmarkers(lat = 18.2, lng = -69.00, popup = "isla catalina") }) observeevent(input$laparguera, { dt::renderdatatable(dt::datatable(parguera) }) } shinyapp(ui, server)
above code, trying action button laparguera display dataframe. (yes, know it's plane data, not coral data, want work first). why action button not working?
you call renderdatatable()
never specify it's supposed go. need datatableoutput()
object in ui. like
ui <- fluidpage( titlepanel("noaa caribbean coral data"), leafletoutput("mymap"), p(), actionbutton("laparguera", "la parguera data"), actionbutton("mona", "mona island data"), actionbutton("isla", "isla catalina data"), dt::datatableoutput('tbl') )
then should have
observeevent(input$laparguera, { output$tbl <- dt::renderdatatable(dt::datatable(parguera)) })
in server()
function.
Comments
Post a Comment