1

我有一个简单的闪亮应用

#ui.r
navbarPage(
  "Application",
  tabPanel("General",
           sidebarLayout(

             sidebarPanel(
               uiOutput("book1"),
               uiOutput("book4"),
               uiOutput("book5")


              ),
             mainPanel(
               DT::dataTableOutput("hot3"),
               br(),
               rHandsontableOutput("hot5")
             )
           )))
#server.r
library(shiny)
library(DT)
library(rhandsontable)
server <- function(input, output,session) {



  output$book1<-renderUI({
    numericInput("bk1", 
                 "Items in test", 
                 value = 1)
  })
  output$book4<-renderUI({
    numericInput("bk4", "From",
                 value = 1,
                 min=1,max=input$bk5)


  })
  output$book5<-renderUI({
    numericInput("bk5", "To",
                 value = 1,
                 min=1,max=input$bk1)


  })


  rt2<-reactive({
    DF=data.frame(
      Sel= rep(TRUE, as.numeric(input$bk5-input$bk4+1)),
      Id= (input$bk4:input$bk5),
      Label=paste("Item",input$bk4:input$bk5),
      Pf=as.integer(rep.int(0,as.numeric(input$bk5-input$bk4+1))),
      stringsAsFactors = FALSE
    )
  })
  output$hot5 <-renderRHandsontable({


    rhandsontable(rt2(),width=300,height = 300)


  }) 


}

如您所见,我有 3 selectInput()。从第一个开始,我决定了我的数据帧的总行数,然后我使用另外 2 个作为我显示的行范围。我的最终目标是实现同时显示多个范围。例如显示从 1 到 5 的行,然后选择从 7 到 8 的行,依此类推。当然,这可以通过其他 selectInputs 来实现,但这并不实用。我在想是否可以通过 atextinput()或可以采用多个值的东西来实现。我不知道这是否可以做到,所以我对创意持开放态度。 在此处输入图像描述

4

0 回答 0