首页 > 解决方案 > 闪亮的 img() 函数,我如何让图像出现?

问题描述

我正在尝试使用 Shiny,但我的 img() 函数不起作用。我已将它放在www包含我的app.R文件的文件夹中的目录调用中,并尝试同时使用 .jpg 和 .png 但图像没有出现。

我闪亮的应用程序的代码是

ui <- fluidPage(
  titlePanel("Customers"),

 sidebarLayout(
    sidebarPanel(
  h1("Choose Dataset"),
  br(),
  br(),
  br(),
  br(),
  br(),

  img(scr = "Logo.jpg", height = 100, width = 150)),


mainPanel(
  h1("Results"),
  p("The results are as follows")
    )
 )
)
# Define server logic ----
server <- function(input, output) {

}

# Run the app ----
shinyApp(ui = ui, server = server)

我还尝试了其他建议使用runApp它的答案也没有奏效。

谁能帮忙解释为什么图像不想出现?

我现在收到以下错误:

Warning in pngfun(filename = filename, width = width, height = height, res = res,  :
  unable to allocate bitmap
Warning in pngfun(filename = filename, width = width, height = height, res = res,  :
  opening device failed
Warning: Error in pngfun: unable to start png() device
  [No stack trace available]

谢谢

标签: rshinyshinydashboard

解决方案


你有一个小错字(scr 而不是 src)......试试这个:

img(src = "Logo.jpg", height = 100, width = 150))

如果 Logo.jpg 在 www/ 中,它应该可以工作


推荐阅读