【问题标题】:How to implement renderImage function如何实现renderImage函数
【发布时间】:2019-11-12 09:57:56
【问题描述】:

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

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

还是不行

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

output$d <- renderImage({ 
                        list(src= "driveaxle.png",
                        filetype = "image/png",
    )}), deletefile = False}

【问题讨论】:

  • deleteFile = FALSE(大写字母)?
  • “不工作”是什么意思?您收到错误消息吗? False 必须是FALSEfiletype 后面有一个逗号要删除,deletefile 必须是deleteFile

标签: shiny shinydashboard rscript


【解决方案1】:

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

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

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

服务器.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)


  }

输出如下:

你可以在这里阅读:https://shiny.rstudio.com/articles/images.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-28
    • 1970-01-01
    • 1970-01-01
    • 2022-07-29
    • 2021-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多