当点击这个verbatimTextOutput时,我想要显示一个绘图输出而不是我的verbatimTextOutput。我如何更改我的代码来实现这一点?我没有设法找到获取clickevent的方法。
library(ggplot2)
library(shiny)
ui <- fluidPage(
fluidRow(
verbatimTextOutput("myFirstText")
)
)
server <- function(input, output) {
output$myFirstText=renderText({
"Click on this text to see a histogram of the AirPassengers-data instead of this very text."
})
output$myPlot=renderPlot({
hist(AirPassengers)
})
}
shinyApp(ui, server)
发布于 2018-02-26 15:02:21
我不确定是否真的有可能做你想做的事情。但是您可以使用shinyjs
包来拉近距离。您可以尝试:
ui <- fluidPage(
shinyjs::useShinyjs(),
fluidRow(
a(id = "toggleAdvanced", "Click on this text to see a histogram of the AirPassengers-data instead of this very text.", href = "#"),
shinyjs::hidden(
div(id = "advanced",
plotOutput("myPlot")
)
)
)
)
server <- function(input, output) {
shinyjs::onclick("toggleAdvanced",
shinyjs::toggle(id = "advanced", anim = TRUE))
output$myPlot=renderPlot({
hist(AirPassengers)
})
}
shinyApp(ui, server)
https://stackoverflow.com/questions/48991081
复制相似问题