2 回答

TA貢獻1797條經(jīng)驗 獲得超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條經(jīng)驗 獲得超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. 當它發(fā)生變化時,它會更新output$title.
添加回答
舉報