How can I reactively add actionButtons to the tableOutput

0 votes
library(shiny)
# ui ##########################
ui <- fluidPage(
   fileInput("csv", label="",
      multiple = TRUE,
      accept = c("text/csv", ".csv")),
   tags$hr(),
   actionButton("show.tbl", "SHOW TABLE"),
   tableOutput("my_tbl")
   )
# server #########################
server <- function(input, output) {
   tbl <- data.frame(Example = LETTERS[1:10]) # will be reactive in reality
   output$my_tbl <- renderTable({
      if(input$show.tbl == 1)
         tbl
    })
 }
# app ######################
shinyApp(ui, server)

How can I reactively add actionButtons to the tableOutput?

Dec 6, 2018 in Data Analytics by Ali
• 11,360 points
1,202 views

1 answer to this question.

0 votes

Use DT for this purpose:

library(shiny)
library(DT)

ui <- fluidPage(
    verbatimTextOutput(outputId = 'vb'),
    dataTableOutput(outputId = 'table')
)

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

    yourData <- reactive({
        return(mtcars)
    })

    output$vb <- renderPrint({
        req(input$table_rows_selected, cancelOutput = TRUE)
        row_id <- input$table_rows_selected

        row_selected <- yourData()[row_id,]

        return(row_selected)
    })

    output$table <- renderDataTable({

        datatable(
            data = yourData(),
            selection = 'single'
        )
    })
}

shinyApp(ui, server)
answered Dec 6, 2018 by Maverick
• 10,840 points

Related Questions In Data Analytics

0 votes
1 answer

How can I import a file in R without giving the destination/file path to the specified file?

You can use the window explorer to ...READ MORE

answered Aug 28, 2018 in Data Analytics by Abhi
• 3,720 points

edited Aug 28, 2018 by Vardhan 2,994 views
+1 vote
2 answers
0 votes
1 answer

How can I add line to show mean for each barplot, not for all dataset?

Hey ranjith,  Use geom_hline() function to add reference lines ...READ MORE

answered Oct 14, 2019 in Data Analytics by Cherukuri
• 33,030 points
603 views
0 votes
1 answer

How can I use parallel so that it preserves the list of data frames

You can use pmap as follows: nc <- ...READ MORE

answered Apr 4, 2018 in Data Analytics by kappa3010
• 2,090 points
1,072 views
+1 vote
1 answer

Error saying "could not find function "shinyUI"" in shiny R

Its a small spelling mistake that you've ...READ MORE

answered Nov 28, 2018 in Data Analytics by Maverick
• 10,840 points
2,626 views
+1 vote
1 answer

Error saying "could not find function dashboardPage" in shiny R

Include this line in the code: Library(shinydashboard) READ MORE

answered Nov 29, 2018 in Data Analytics by Maverick
• 10,840 points
3,659 views
0 votes
1 answer

How do I copy an excel file to my Rconsole with all the missing values?

You can use read.table function in the ...READ MORE

answered Nov 16, 2018 in Data Analytics by Maverick
• 10,840 points
553 views
0 votes
1 answer

How do I add Icons to my messages on my dashboard which I’m creating using shiny r?

Try something like this: dashboardHeader(title="Edureka", dropdownMenu type = "message", messageItem(from = ...READ MORE

answered Nov 30, 2018 in Data Analytics by Maverick
• 10,840 points
875 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP