r - 如何在 R Shiny 标题中放置图像

标签 r shiny

所以我正在使用 R Shiny,我想在标题中的文本右侧放置一个图像。除了标题旁边之外,我似乎可以将图像放置在应用程序中的任何位置。你能不能不把图片放在titlePanel()功能?这是我正在使用的代码片段:

library(shiny)

# Define UI for random distribution application 
shinyUI(fluidPage(#theme="bootstrap.css",

  # Application title
  titlePanel("My Title",img(src = "picture.jpg", height = 50, width = 100)),
  sidebarLayout(
    sidebarPanel(

所以当我使用上面的代码时,我似乎在应用程序的任何地方都看不到我的图像......

最佳答案

一种方法是按照这篇文章中的说明进行操作:How can I insert an image into the navbar on a shiny navbarPage() (SO 猎犬会将其视为重复攻击)。

在您的工作目录中创建一个名为“www”的文件夹,并将“picture.jpg”放入其中:

| shinyApp/
    | ui.R
    | server.R
 | www/
    | picture.png

将您的图片包含在带有 div 的 titlePanel 中:

ui.r
library(shiny)

# Define UI for random distribution application 
shinyUI(fluidPage(#theme="bootstrap.css",

  # Application title
  titlePanel(title=div(img(src="picture.jpg"), "My Title")),
  sidebarLayout(
    sidebarPanel(
    )
  )
)
)

enter image description here

关于r - 如何在 R Shiny 标题中放置图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36182535/

相关文章:

r - 响应式(Reactive)值(value)和响应式(Reactive)表达有什么区别?

r - 将 react 输入传递到 R Shiny 中的绘图轴

r - SelectInput Value update based on previous SelectInput in R shiny

R-merge()在ALL列中返回NA,尽管all.x = T

mysql - 如何通过R向MySQL添加追加数据?

r - 带有条件面板的 Shiny 仪表板中的动态菜单

r - 使用 ddply 和 lapply 聚合包含 NA 的类别?

r - R 中未定义的列错误

r - Downloadhander(保存情节)以获取 Shiny 的基本情节

R Shiny 销毁观察事件