如何实现renderImage函数

我无法通过闪亮的网页中的子目录路径上传图像。

  1. 我创建了一个名为“ www”的子目录文件夹,并放置了图像。
  2. 我也尝试过使用URL。

仍然无法正常工作

imageOutput("d",width = 300,height = 500)

output$d <- renderImage({ 
                        list(src= "driveaxle.png",filetype = "image/png",)}),deletefile = False}
wsk520520 回答:如何实现renderImage函数

我尝试了您的代码。它需要修改几个区域。 首先,您需要在www文件夹下创建一个名为images的文件夹。还需要从单独的变量中读取文件名。

我尝试过,它看起来像: UI.R

fluidPage(
  sidebarLayout(
    sidebarPanel(
      "This is Sidebar"
    ),mainPanel(imageOutput("d",width = 300,height = 500)
              )
  )
)

Server.R

function(input,output) {
  output$d <- renderImage({ 
    filename <- normalizePath(file.path('./www/images','studio logo.jpg'))

    list(src = filename,contentType = 'image/png',alt = "This is alternate text")
  },deleteFile = FALSE)


  }

输出如下:

enter image description here

您可以在此处阅读:https://shiny.rstudio.com/articles/images.html

本文链接:https://www.f2er.com/3118443.html

大家都在问