R Shiny (only alt text)

Using the code below, I am only getting the alt text to appear. Any suggestions on what may be the problem?

From server.R:

output$face <- renderImage({
list(src = "http://www.clipartbest.com/cliparts/yco/GGE/ycoGGEacE.png",
filetype = "image/png",
alt = "YOU MUST BE KIDDING ME!")
}, deleteFile = FALSE)

From ui.R:

imageOutput("face")

Thanks,

Chad

Adding to the explanation of the problem - I am not just trying to display the image. Rather, I am trying to make it reactive - and display a different image, based on inputs... per the server.R code below:

output$imagegauge <- renderImage({
if (is.null(IRR_calc()))
return(NULL)

if (IRR_calc() > .085) {
return(list(
src = "http://www.i2symbol.com/images/abc-123/o/white_smiling_face_u263A_icon_256x256.png",
contentType = "image/png",
alt = "Smiley Face"
))
} else  {
return(list(
src = "http://www.clipartbest.com/cliparts/yco/GGE/ycoGGEacE.png",
filetype = "image/png",
alt = "Sad Face"
))
}
}, deleteFile = FALSE)

Thanks again,

Chad


renderImage takes a file as src input rather then a url. You can just include this image directly using tags$img :

library(shiny)
runApp(list(
  ui = fluidPage(
    titlePanel("Hello Shiny!"),
    sidebarLayout(
      sidebarPanel(
        numericInput('n', 'Number of obs', 100),
        numericInput('m', 'Select image (Happy (1) or Sad(2))', 1, min = 1, max = 2),
        uiOutput('test')
      ),
      mainPanel(
        plotOutput('plot')
      )
    )
  ),
  server = function(input, output) {
    output$plot <- renderPlot({ hist(runif(input$n)) })
    output$test <- renderUI({
      images <- c("http://www.i2symbol.com/images/abc-123/o/white_smiling_face_u263A_icon_256x256.png"
                  , "http://www.clipartbest.com/cliparts/yco/GGE/ycoGGEacE.png")
      tags$img(src= images[input$m])

    })
  }
))

在这里输入图像描述

链接地址: http://www.djcxy.com/p/79872.html

上一篇: 像R中的调用

下一篇: R闪亮(仅替代文字)