Hello堆栈溢出, 有谁知道如何(或是否可能)从renderDataTable的反应式输出中调用列?
我有一个结合了DT
和pastecs
反应性的ShinyApp(flexdashboard)。但是,我想更进一步,将输出与shinyalert
合并。
代码:
Column
--------------------------------------------------------------
'''{r}
library(DT)
library(pastecs)
library(shinyalert)
renderDataTable({...
y<-as.data.frame(stat.desc(x$Count), stringsAsFactors = FALSE)
row.names(y) = c(..."std.dev",...)
DT::datatable(y,options = list(pageLength = 15))
'''
上面的脚本已被缩写为省事,但请放心,输出将按预期方式呈现,.app中的“ y”更新将对从较早设置的“ selectInput”选项卡中进行的用户选择起反应。
但是,我想添加更多功能,例如:如果满足某些条件,则呈现闪亮警报。这是我尝试过的,但没有成功:
#continuation from within the same Column as [renderDataTable]
...
DT::datatable(y,options = list(pageLength = 15))
useShinyalert()
if (y$std.dev > 10) shinyalert(title = "Warning! Standard Deviation for the applied filters is greater that 10", type = "error") else shinyalert(title = "No extreme deviations observed for the applied filters", type = "info")
警告:if:参数的长度为零时出错
尝试2:
#Wrap 'y' with ()
useShinyalert()
if (y()$std.dev > 10) shinyalert(title = "Warning! Standard Deviation for the applied filters is greater that 10", type = "error") else shinyalert(title = "No extreme deviations observed for the applied filters", type = "info")