在showNotification中打印列mean from reactiveValue,即data.frame
我有一个反应值,即data.frame,希望:在showNotification中打印列mean from reactiveValue,即data.frame,r,shiny,R,Shiny,我有一个反应值,即data.frame,希望: 仅更新反应值的1列 仅打印1列无功值的平均值 我不明白为什么我的代码不起作用: library(shiny) ui <- fluidPage(actionButton("printMean", "print mean"), actionButton("setZeroToSepal.Length", "setZeroToSepal.Length")) dt <- iris server <-
library(shiny)
ui <- fluidPage(actionButton("printMean", "print mean"),
actionButton("setZeroToSepal.Length", "setZeroToSepal.Length"))
dt <- iris
server <- function(input, output){
values <- reactiveValues(x = dt)
observeEvent(input$printMean, {
d <- values$x
showNotification(mean(d$Sepal.Length), type = "default")
})
observeEvent(input$setZeroToSepal.Length, {
values$x$Sepal.Length <- rep(0, nrow(values$x))
})
}
shinyApp(ui, server)
库(闪亮)
ui问题在于showNotification
。我相信它需要一个字符,尽管它没有很好的文档记录,并且通过查看源代码我无法确认这一点。你可以用
showNotification(as.character(mean(d$Sepal.Length)), type = "default")
它应该会起作用