如何使用确认选择按钮根据上面现有数据表中的行选择生成和显示新数据表

时间:2019-01-21 05:30:47

标签: r datatables shiny

根据从现有数据表中选择的行来保存和显示数据表

我需要在r-shiny应用程序中显示一个数据表,并根据用户的行选择(最好使用复选框)并单击“确认选择”按钮,将数据加载并显示在另一个数据库中(在主表下方)

library(shiny)
library(ggplot2)  # for the diamonds dataset

ui <- fluidPage(
  title = "Examples of DataTables",

    mainPanel(
      tabsetPanel(
        id = 'dataset',
        tabPanel("Global Library", DT::dataTableOutput("mytable1")),
        tabPanel("mtcars", DT::dataTableOutput("mytable2")),
        tabPanel("iris", DT::dataTableOutput("mytable3"))
      )
    )

)

library(shiny)

# Define server logic required to draw a histogram
server <- function(input, output) {

  # choose columns to display

  output$mytable1 <- DT::renderDataTable({
    DT::datatable(data1, options = list(orderClasses = TRUE ,autoWidth=TRUE),filter = 'top')
  })

  # sorted columns are colored now because CSS are attached to them
  output$mytable2 <- DT::renderDataTable({
    DT::datatable(mtcars, options = list(orderClasses = TRUE))
  })

  # customize the length drop-down menu; display 5 rows per page by default
  output$mytable3 <- DT::renderDataTable({
    DT::datatable(iris, options = list(lengthMenu = c(5, 30, 50), pageLength = 5,autoWidth=TRUE))
  })

}

我需要在第一个选项卡的表格下方添加一个名为“保存详细信息”的按钮,并且需要在该按钮下方创建并显示选定的输出,以显示第一个表格中的选定输出。

我是stackverflow的新手,请提供帮助,请忽略其他代码

0 个答案:

没有答案