【发布时间】:2015-06-10 13:11:25
【问题描述】:
我尝试使用从闪亮输入传递的列表元素填充闪亮列表。该列表应累积所有做出的选择。该列表最终应该被发送到闪亮的输出。实际上我已经得到了一个可以发送到输出的列表。然而,这个列表的长度总是只有 1,并且这个单个元素会随着输入而更新。实际上我只对列表的“名称”感兴趣,这就是为什么我将值 1 分配给每个名称元素:
用户界面shinyUI(
fluidRow(
column(1,
# reactive input
selectInput("Input1",
label = "Select Parameter 1",
choices = c("none",letters[1:16]),
multiple = T),
selectInput("Input2",
label = "Select Parameter 2",
choices = c("none",c(1:24) )
multiple = T),
# printout of list
htmlOutput("printoutList")
) # end of column
) # end of fluid row
) # end of Shiny UI
闪亮的.R
# create an empty list
container <- list()
shinyServer(function(input, output) {
# pass over input to reactive
inputInfo <- reactive({
if(input$Input1 == "none" | input$Input2 == "none") {
"-"
} else {
paste(input$Input1 ,input$Input2, sep = "")
}
})
# fill list and pass over list to output
output$printoutList <- renderUI({
container[[inputInfo()]] <- 1
paste("You have chosen: ", names(container), sep = "")
})
)} #end of shinyServer function
知道如何解决这个问题吗?我已经尝试了很多......不幸的是我对 R 很陌生,尤其是闪亮的!我真的很感激任何帮助!谢谢!
【问题讨论】: