【问题标题】:How to print file to Shiny using renderText如何使用 renderText 将文件打印到 Shiny
【发布时间】:2017-06-19 21:32:57
【问题描述】:

我在这里遗漏了一些东西,因为图像没有显示。

谢谢。

shinyServer(function(input, output) {
  src = "einstein.jpg"
  print(file.exists(src))
  out = '<img src="einstein.jpg" style=width:304px;height:228px;>'
  output$text3<-renderText(out)

  })

shinyUI(fluidPage(

  htmlOutput("text3")

))

【问题讨论】:

  • 您是要显示 jpg 还是与 html 标签关联的代码?

标签: html r shiny


【解决方案1】:

如果您将图片einstein.jpg 放在应用的img/ 子文件夹中,您可以使用addResourcePath 来允许访问它:

library(shiny)
shinyApp(ui=fluidPage(htmlOutput("text3")),
         server=(function(input, output) {
           addResourcePath("foo", "img")  
           out = '<img src="/foo/einstein.jpg" style=width:304px;height:228px;>'
           output$text3<-renderText(out)
         }))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-11-19
    • 1970-01-01
    • 1970-01-01
    • 2018-02-28
    • 2013-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多