我是Shiny的新手。我正在处理仪表板。我正在使用 renderUI 来获取一些输入。两天来,代码运行良好,但今天突然开始给我带来问题。任何帮助将非常感激。
用户界面代码:
ui <- fluidPage(
column(width =6,
box(width = NULL, status = "warning",solidHeader = TRUE,
title = "Topics Level",
selectInput(inputId = "Vis_level_select",
label = "",
selected = "Main Topics",
choices = c("Main Topics","Sub-Topics")
)
)
),
## Topic Number Output
column(width = 6,
box(width = NULL, status = "warning",solidHeader = TRUE,
title = "Select the topic for which Sub Topics are to be shown",
uiOutput("topic_no_select")
)
))
服务器代码:
server <- function(input, output){
## Topic number output
output$topic_no_select <- renderUI({
if(input$Vis_level_select == "Main Topics"){
selectInput(inputId = "main_topic_no", label = "", choices = "N/A", selected = "N/A")
} else{
selectInput(inputId = "main_topic_no", label = "", choices = c(1:10), selected = 1)
}
})
## LDAvis output
output$LDAvis_output <- renderVis({
if(input$Vis_level_select == "Sub-Topics"){
viz_file <- paste0("Viz_Sub_topics_Main_Topic_",input$main_topic_no)
} else if(input$Vis_level_select == "Main Topics"){
viz_file <- "Viz_Sub_topics_Main_Topics"
}
get(viz_file)
})
}
输出中的 if 语句LDAvis
给了我空白,它给了我一个错误,说Viz_Sub_topics_Main_Topic_
找不到。一旦我改变了input$Vis_level_select
第一部分的值,LDAvis
但第二部分仍然不起作用。我无法理解为什么会这样。
请让我知道这是否只是一个会在重新启动时消失的错误。