2 回答
TA贡献1797条经验 获得超6个赞
library(shiny)
js <- "
$(document).ready(function(){
$('#title_change').on('change', function(){
var title = $('input[name=title_change]:checked').val();
$('span.navbar-brand').text(title);
});
});
"
ui <- fluidPage(
tags$head(tags$script(HTML(js))),
navbarPage(
"Project Title",
tabPanel(
title = "Tab 1",
radioButtons("title_change", label = "Change title of App", choices = c("Title 1", "Title 2"))
)
)
)
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
TA贡献1895条经验 获得超3个赞
你可以用一个shiny::textOutput和shiny::renderText
library(shiny)
ui <- navbarPage(textOutput("title"),
tabPanel(title = "Tab 1",
radioButtons("title_change", label = "Change title of App", choices = c("Title 1", "Title 2"))
)
)
server <- function(input, output) {
output$title <- renderText({
input$title_change
})
}
shinyApp(ui = ui, server = server)
当您更改单选按钮时,它会更改input$title_change. 当它发生变化时,它会更新output$title.
添加回答
举报