R 如何让标题面板从服务器中提取文本?
有没有什么方法可以让动态标题面板标题直接从UI中提取,就像下面这样?如果不可能,有没有可能在titlepanel的正下方有一个类似于titlepanel的第二行R 如何让标题面板从服务器中提取文本?,r,shiny,R,Shiny,有没有什么方法可以让动态标题面板标题直接从UI中提取,就像下面这样?如果不可能,有没有可能在titlepanel的正下方有一个类似于titlepanel的第二行 # Define UI ---- ui <- fluidPage( ##Whatever UI code here titlepanel_text = paste0("Some string", variable_with_text) ) # Define server logic ---- server <- f
# 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)
您可以插入此类代码来构造标题面板
# Application title
titlePanel(
fixedRow(
column(9,
"My Template",
fixedRow(
column(9,
paste0("Author : ", author)
),
column(3,
paste0("date : ", today(tzone = ""))
)
)
)
) ),
实现这一点的典型方法是通过renderUI。@Ameya我应该如何使用renderUI?类似于昨天早些时候的Q,可能对您也有帮助;