The two reactive dataframes are dynamic. But the output is getting merged

让人想犯罪 __ 提交于 2019-12-11 06:33:36

问题


The outputs (2 dataframes) are getting merged. Since the dataframe is dynamic, I am expecting the output to be displayed one after the other. (Flights and Tactics are tabpanels)

ui <- fluidPage( 
  fluidRow(
    column(3, wellPanel(
      textInput("account","Enter the Account Name",""),
      tags$hr(),
      actionButton("goButton", "Go")
    )),
    mainPanel(
        tabsetPanel(
          tabPanel("Flight",            
                   textInput("flightname","Enter the flight Name","")
                   tags$hr(),
                   actionButton("go", "Go")),
          tabPanel("Tactic", 
                   textInput("tacticname","Enter the tactic Name",""),
                   tags$hr(),
                   actionButton("go1", "Go"))
        ),
      column(3,dataTableOutput('mytable1')),
      conditionalPanel(
        condition = "input.go1 != 0",
        column(3,dataTableOutput('mytable2')))
     )
  ))
server <- function(input, output) {
rv <- reactiveValues(fli = data.frame("FlightName" = character(), "AddedValue" = character()))

  observeEvent(input$go, {
    # Bind new row to rv$fli
    rv$fli <- rbind(
      rv$fli, 
        data.frame("Account"=input$account"FlightName"=input$flightname)
    )
  })

  rv1 <- reactive({rv$fli})

  output$mytable1  <- DT::renderDataTable(
    DT::datatable(
      rv1(),
      extensions = 'Buttons',
      options = list(
        paging = TRUE,
        dom = 'tB',
        buttons = c('copy', 'csv', 'excel','pdf')
      ),
      class = "display"
    ))

  rv <- reactiveValues(tact = data.frame("TacticName" = character()))

  observeEvent(input$go1, {
    rv$tact <- rbind(
      rv$tact, 
      data.frame("Account"=input$account,"TacticName"=input$tacticname))
  })

  rvt <- reactive({rv$tact})
}}

Using the similar DT::renderDataTable to display rvt(). In the ui part, I am using column(3,dataTableOutput('mytable1')) and column(3,dataTableOutput('mytable2')).

来源:https://stackoverflow.com/questions/56595027/the-two-reactive-dataframes-are-dynamic-but-the-output-is-getting-merged

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!