我有一个简单的闪亮应用程序:
#ui.r
navbarPage(
"Application",
tabPanel("General",
sidebarLayout(
sidebarPanel(
uiOutput("tex2"),
uiOutput("book3")
),
mainPanel(
DT::dataTableOutput("hot3")
)
)))
#server.r
library(shiny)
library(DT)
server <- function(input, output,session) {
output$tex2<-renderUI({
numericInput("text2","#tests",
value = 1,
min=1
)
})
output$book3<-renderUI({
selectInput("bk3",
"Change Name",
choices=(paste("Test",1:input$text2)))
})
rt1<-reactive({
data.frame(
Label=paste("Test",1:input$text2),
stringsAsFactors = FALSE)
})
output$hot3 <-DT::renderDataTable(
rt1(),
editable = TRUE
)
}
您可以使用上面的selectInput()
来在第二个selectinput()
和表中添加或删除新测试。我想要的是从数据表中选择一行(例如“ Test 1”),然后能够编辑此特定的selectInput()
值(“ Test 1”到“ Test ABC”),并将显示该值在表格中显示为“测试ABC”。基本上,我不知道是否甚至可以使用此功能(编辑selectInput()
选项)还是首选textInput()。
答案 0 :(得分:1)
I would include two req(input$text2)
in the renderUI
and in the reactive
. To edit the Labels in the Table, you just have to double-click the item and change the name.
server <- function(input, output,session) {
output$tex2<-renderUI({
numericInput("text2","#tests",
value = 1,
min=1
)
})
output$book3<-renderUI({
req(input$text2)
selectInput("bk3",
"Change Name",
choices=(paste("Test",1:input$text2)))
})
rt1<-reactive({
req(input$text2)
data.frame(
Label=paste("Test",1:input$text2),
stringsAsFactors = FALSE)
})
output$hot3 <-DT::renderDataTable(
rt1(),
editable = TRUE
)
}