r - R闪亮单选按钮中的开关输出
问题描述
我正在开发一个闪亮的应用程序,我正在使用radioGroupButtons
ShinyWidgets。因此,对于每个按钮,我都试图切换到不同的输出,如表格或绘图。如何将单选按钮链接到输出
library(shinyWidgets)
library(shinipsum)
library(htmlwidgets)
ui <- navbarPage(
div(
id = "section1-1",
radioGroupButtons(
inputId = "Id069",
# label = "Choose a graph :",
choices = c(
`<i class='fa fa-bar-chart'></i>` = "bar",
`<i class='fa fa-line-chart'></i>` = "line",
`<i class='fa fa-pie-chart'></i>` = "pie"
),
justified = TRUE
)
)
)
server <- function(input, output, session) {
# observe({
# x <- input$inRadioButtons
#
# # Can also set the label and select items
# updateRadioButtons(session, "inRadioButtons2",
# label = paste("radioButtons label", x),
# choices = x,
# selected = x
# )
# })
output$plot <- renderPlot({
random_ggplot()
})
}
shinyApp(ui, server)
解决方案
在服务器端,您可以像这样访问输入 ID:
Value = input$Id069
因此,将这样的逻辑添加到服务器端(在 output$plot 中):
If (Value == x) {
Plot1()
} else {
Plot2()
}
您可能想查看 UI 上的条件面板。
推荐阅读
- python - 将变量传递到 Spyder 中的命令行
- r - 基于 R 中的其他两个变量分解一个变量
- python - 在 Python 中使用 Girvan Newman 算法时根据社区的颜色节点
- android - MockK 中的 ArgumentMatchers
- javascript - 如何放置图像,在画布后面
- mediawiki - 如何为我的网站设置 MediaWiki
- android - 如何将 Collectors.toList 用于 ArrayList?
- javascript - 通过 JSON 格式的 AJAX 将图像发送到 Rocket 服务器的正确方法
- c# - 使用夏令时安排日期
- sql - 使用此代码保持打开游标超出