【发布时间】:2020-08-30 06:37:33
【问题描述】:
朋友们可以帮我在闪亮的导航栏页面中插入一个图形。我想在我的 navbarPage 中删除书面文字“模拟”并插入附图。这可以在闪亮的情况下进行吗?任何帮助表示赞赏。可执行代码如下。
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",
【问题讨论】:
-
这能回答你的问题吗? Logo instead of application title Shiny
-
不幸的是我做不到。我在插入的代码和图像上方插入。你知道错误可能是什么吗?
-
我看到错误朋友在src。如何找到将图像放在 src 上的目录?
-
您应该按照answer 中的说明将图像放在 www 文件夹中。您可能还需要在 ui.R 和 server.R 文件中拆分 app.R 文件。
标签: r shiny shinythemes