r - 如何让 R Shiny 标题面板从服务器中提取文本?
问题描述
有没有办法让动态 titlePanel 标题直接从 UI 中提取,如下所示?如果不可能,是否可以在标题面板正下方有类似于标题面板的第二行?
# Define UI ----
ui <- fluidPage(
##Whatever UI code here
titlepanel_text = paste0("Some string", variable_with_text)
)
# Define server logic ----
server <- function(input, output) {
titlePanel("title panel"),
#Rest of server code here
}
解决方案
在服务器中渲染文本并在 UI 中抓取文本输出:
library(shiny)
# Define UI ----
ui <- fluidPage(
##Whatever UI code here
titlePanel(textOutput("title_panel")),
sidebarLayout(
sidebarPanel(),
mainPanel(h1("text"))
)
)
# Define server logic ----
server <- function(input, output) {
output$title_panel <- renderText({
paste0("This is the date/time: ", Sys.time() )
})
}
shiny::shinyApp(ui, server)
推荐阅读
- java - 带有定时刷新bean的Spring自定义范围
- c# - Temporary Index for a while loop
- wix - Wix 安装程序次要升级 exe 保持许可证不变
- python - 有没有办法将图像从散景 python 代码合并到独立的 HTML 中?
- python - 使用二维矩阵指定行和列的索引二维数组
- c++ - 如何在三元运算符中对齐冒号?
- flutter - 如何在 Flutter Better_player 上添加视频标题?
- javascript - 在浏览器中的 Tab 开关上暂停视频,但应在最小化浏览器窗口时继续播放
- python - 测试ndarray中子数组的存在
- c++ - 如何查找二维向量是否包含给定向量..?