【发布时间】:2019-09-15 08:57:32
【问题描述】:
我正在尝试在我的 Shiny 仪表板中添加一个 HTML 链接。理想的解决方案是通过单击侧栏上的项目将用户定向到网站。但是,我找不到这样做的解决方案。
这是我的代码:
library(shiny)
library(shinydashboard)
header <- dashboardHeader(
title = "Test Dashboard"
)
sidebar <- dashboardSidebar(
sidebarMenu (
menuItem("Test",startExpanded = TRUE,
menuSubItem("Dashboard", tabName = "tab"),
menuSubItem("Link")
)
)
)
body <- dashboardBody(
tabItems(
tabItem(tabName = "tab",
box(title = "Table", width = 10, status = "warning", DT::dataTableOutput("table"))
)
)
)
ui <- dashboardPage(header, sidebar, body)
server <- function(input, output) {
output$table = DT::renderDataTable({
DT::datatable(tabledata)
})
}
shiny::shinyApp(ui, server)
This 是当前侧边栏布局。
目前,我只在 Dashboard 选项卡中显示数据表,Link 选项卡中不显示任何内容。
我想知道是否可以通过单击侧边栏上的标签名称 "Link" 将用户重定向到网站 (https://shiny.rstudio.com/)。
我知道解决方案可能是在 Server 中呈现 HTML 链接并在 UI 中输出。请指教。
提前致谢。
【问题讨论】:
标签: javascript html r shiny rstudio