根据ShinyApp中的输入渲染不同的图像

时间:2015-11-10 15:56:52

标签: r shiny

我正在构建一个ShinyApp,根据selectInput面板,可以根据多个变量对不同的图表进行着色,并且还应根据用户的选择插入不同的图像。面板。

我无法渲染图像。我只是得到一个他们应该出现的空白区域。

我很确定我在这里遗漏了一些明显的东西,但我仍在尝试闪亮而且无法弄明白。谢谢你的帮助。

我的代码的相关部分(如果您需要更多,请告诉我):

服务器:

shinyServer(function(input, output) {
     output$Imagen<- renderImage({
        if(input$ColorBy=="Raza") Leg<-"Razaimagen.png"
        if(input$ColorBy=="Log") Leg<-"Logimagen.png"

        list(src=Leg)
         })      
 })

UI:

shinyUI(fluidPage(
         fluidRow(
                  column(3, 
                         h3("Imagen", align = "center"),
                         imageOutput(outputId="Imagen")
            ))
        ))

&#34; Razaimagen.png&#34;和&#34; Logimagen.png&#34;我快乐地坐在我的www文件夹中。如果我直接在img(src="Razaimagen.png")

中尝试ui.R,它们的效果会很好

1 个答案:

答案 0 :(得分:0)

您删除图片,请使用:

  output$Imagen<- renderImage({
    if(input$ColorBy=="Raza") Leg<-"www/Razaimagen.png"
    if(input$ColorBy=="Log") Leg<-"www/Logimagen.png"
    list(src=Leg)
  }, deleteFile = FALSE)