2016-12-30 76 views
1

enter image description here闪亮的NavBar添加额外的信息

因为我的代码是长我从here

我试图从here加入以下代码(最后tabPanel后)考虑的示例代码。但没有运气。

tags$script(HTML("var header = $('.navbar > .container'); 
         header.append('<div Company name text here>')")) 

所有我想要的是一个纯文本(信息)在NavBar的右侧。

回答

2

下面的代码给你你想要的。主要问题是浏览html标签。

library(shiny) 


server <- function(input, output, session) { 
    output$plot <- renderPlot({ 
    plot(cars, type=input$plotType) 
    }) 

    output$summary <- renderPrint({ 
    summary(cars) 
    }) 

    output$table <- DT::renderDataTable({ 
    DT::datatable(cars) 
    }) 
} 


ui <-shinyUI(navbarPage("Navbar!", 
      tabPanel("Plot", 
        sidebarLayout(
         sidebarPanel(
         radioButtons("plotType", "Plot type", 
            c("Scatter"="p", "Line"="l") 
         ) 
        ), 
         mainPanel(
         plotOutput("plot") 
        ) 
        ) 
      ), 
      tabPanel("Summary", 
        verbatimTextOutput("summary") 
      ), 


      tags$script(HTML("var header = $('.navbar > .container'); 
         header.append('<div style=\"float:right\"><h3>Company name text here</h3></div>'); 
         console.log(header)")) 
)) 

shinyApp(ui = ui, server = server) 

希望它有帮助!