Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shiny 闪亮:如果输入与默认值不同,则显示textOutput()_Shiny_Conditional Statements - Fatal编程技术网

Shiny 闪亮:如果输入与默认值不同,则显示textOutput()

Shiny 闪亮:如果输入与默认值不同,则显示textOutput(),shiny,conditional-statements,Shiny,Conditional Statements,我有一个闪亮的应用程序,有多种不同类型的输入(checkboxGroupInput,sliderInput,dateRangeInput…)和默认选择值。 如果输入值与默认值不同,我试图在仪表板主体顶部显示一条文本消息 ui <- dashboardPage( #one of the inputs dateRangeInput( "date_reception", "Sélectionnez une plage

我有一个闪亮的应用程序,有多种不同类型的输入(
checkboxGroupInput
sliderInput
dateRangeInput
…)和默认选择值。 如果输入值与默认值不同,我试图在
仪表板主体顶部显示一条文本消息

ui <- dashboardPage(
#one of the inputs
dateRangeInput(
            "date_reception",
            "Sélectionnez une plage de dates",
            start = min(dataset_all$date_reception),
            end = max(dataset_all$date_reception),
          ),
#the output to show if input is different from default
textOutput("warning_filters")


----------


)


server <-  function(input, output) {    

observeEvent(input$date_reception,
                   {
                     if ((input$date_reception[1] != min(dataset_all$date_reception)) |
                         (input$date_reception[2] != max(dataset_all$date_reception))) {
                       output$warning_filters <-
                         renderText({
                           "Warning: filters apply"
                         })
                     } else{
                       NULL
                     }
                   })
}


ui当条件为false时,您需要重新分配
warning\u过滤器。现在,
warning\u filters
设置为警告文本,即使在条件不成立时使用函数return
NULL
,实际上也不会更改
warning\u filters
的值。下面的代码应该可以工作

observeEvent(input$date_reception,
                   {
                     if ((input$date_reception[1] != min(dataset_all$date_reception)) |
                         (input$date_reception[2] != max(dataset_all$date_reception))) {
                       output$warning_filters <-
                         renderText({
                           "Warning: filters apply"
                         })
                     } else{
                       output$warning_filters <- NULL
                     }
                   })
}

observeEvent(输入$date\u接收,
{
if((输入$date\u receivement[1]!=min(数据集\u all$date\u receivement))|
(输入$date\u receivement[2]!=max(数据集\u all$date\u receivement))){

输出$warning\u过滤器非常感谢您发现了这个相当愚蠢的错误。