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
设置为警告文本,即使在条件不成立时使用函数returnNULL
,实际上也不会更改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过滤器非常感谢您发现了这个相当愚蠢的错误。