【发布时间】:2021-05-18 21:57:30
【问题描述】:
我正在尝试在输入某些参数后生成一些图表,但是,在输入某些图表时它们会抛出错误,因为尚未输入输入,所以如果值为 null,我就想到了,不要制作图表但附件代码不起作用:
shinyApp(ui =
fluidPage(sidebarPanel(numericInput('x','x', value = NULL),
numericInput('x2','x2', value = NULL),
numericInput('x3','x3', value = NULL)),
mainPanel(renderPlot('plot1'))),
server = function(input, output, session){
condition <- reactive(is.null(input$x) | is.null(input$x2) |is.null(input$x3))
output$plot1 <- renderPlot(if(condition()){NULL}else{plot(1:10,1:10)})
})
我会很感激有办法做到这一点,谢谢。
【问题讨论】:
-
可能使用req function 获取所需参数。您的示例似乎没有产生任何错误,因此很难用于测试可能的解决方案。代码“不工作”究竟如何?
-
谢谢,效果很好!!
标签: r shiny shinydashboard shiny-server