在闪亮的navbarPage中插入图 [英] Insert Figure in shiny navbarPage

查看:243
本文介绍了在闪亮的navbarPage中插入图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友可以帮助我在闪亮的navbarPage中插入一个图形.我想删除文字"Simulation",在我的navbarPage中,并插入附图.这有可能做到闪亮吗?任何帮助表示赞赏.可执行代码如下.

Friends could help me insert a figure into my shiny navbarPage. I would like to remove the written word "Simulation" in my navbarPage and insert the attached figure instead. Is this possible to do in shiny? any help is appreciated. The executable code is below.

library(shiny)
library(shinytables)

ui <- bootstrapPage(
  navbarPage(theme = shinytheme("flatly"), collapsible = TRUE,
              "Simulation", 
  sidebarLayout(
    sidebarPanel(
      sliderInput("bins",
                  "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30)
    ),
    
    sidebarLayout(
      sidebarPanel(
        sliderInput("bins",
                    "Number of bins:",
                    min = 1,
                    max = 20,
                    value = 30),
      ),
      mainPanel(
        plotOutput("distPlot")
      )
    )
  )))

server <- function(input, output) {
  
  output$distPlot <- renderPlot({
    # generate bins based on input$bins from ui.R
    x    <- faithful[, 2]
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    
    # draw the histogram with the specified number of bins
    hist(x, breaks = bins, col = 'darkgray', border = 'white')
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

非常感谢!

ui <- shiny::navbarPage(
  
  title = div(img(src='simulation.jpg',style="margin-top: -14px; padding-right:10px;padding-bottom:10px", height = 60)),
  windowTitle="Simulation",

推荐答案

这项工作可以吗?

library(shiny)
library(shinythemes)
shinyUI(
    navbarPage(title = div("", img(src = "simulation.jpg", id = "simulation", height = "50px",width = "100px",style = "position: relative; margin:-15px 0px; display:right-align;")), 
               theme = shinytheme("flatly"), 
               tabPanel("Simulation",collapsible = TRUE,
                        sidebarLayout(
                            sidebarPanel(
                                sliderInput("bins",
                                            "Number of bins:",
                                            min = 1,
                                            max = 50,
                                            value = 30)
                            ),

                            sidebarLayout(
                                sidebarPanel(
                                    sliderInput("bins",
                                                "Number of bins:",
                                                min = 1,
                                                max = 20,
                                                value = 30)
                                ),
                                mainPanel(
                                    plotOutput("distPlot")
                                )
                            )
                        ))
    )

)

这篇关于在闪亮的navbarPage中插入图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆