2016-03-15 232 views
1

我在Shiny应用程序文件夹的images文件夹中有预渲染的图像。我试图让应用呈现图片EXG.jpeg,但只有替代文字出现。出了什么问题?R闪亮 - 无法显示预渲染图像

\服务器文件

setwd('C:/Users/E0265074/Documents/PrelimShiny/') 

    function(input, output) {output$Option1 = renderUI({ 

    if (input$study == 'EX') { 

    selectInput('differ', label='Patient ID', choices = c('013412-826-001-002','013412-840-001-001','013412-840-001-002','013412-840-001-003','013412-840-001-004')) 

    } 

}) 

output$plot <- renderImage({ 
     return(list(
     src = "./images/EXG.jpeg", 
     contentType = "image/jpeg", 
     alt = "Face" 
    )) 
    }) 

}) 

\ UI文件

library(shiny) 


shinyUI(fluidPage(

    titlePanel('Biomarker Comparison'), 

    sidebarLayout(sidebarPanel(

    tabsetPanel(type = c('tabs'), 

       tabPanel('Plot 1 Options', selectInput('study', label = 'Study Type', choices = c('EX')), 
         uiOutput('Option1'), 
         uiOutput('Option2'), 
         uiOutput('Option3') 

       ), 

       tabPanel('Plot 2 Options', selectInput('studya', label = 'Study Type', choices = c('EX')), 
         uiOutput('Option1a'), 
         uiOutput('Option2a'), 
         uiOutput('Option3a') 
       ) 

    ), 

), 


    mainPanel(imageOutput('img1') 
) 




) 

)) 
+0

你标记为'shiny-server'的任何特定原因? –

回答

2

你没有使用正确的imageOutput标签。 img1是错误的,您需要plot,因为这是output列表条目的命名方式。所以这个工程:

library(shiny) 

u <- shinyUI(fluidPage(
    titlePanel('Biomarker Comparison'), 
    sidebarLayout(sidebarPanel(
    tabsetPanel(type = c('tabs'), 

       tabPanel('Plot 1 Options', selectInput('study', label = 'Study Type', 
                    choices = c('EX')), 
         uiOutput('Option1'), 
         uiOutput('Option2'), 
         uiOutput('Option3') 
       ), 
       tabPanel('Plot 2 Options', selectInput('studya', label = 'Study Type', 
                   choices = c('EX')), 
         uiOutput('Option1a'), 
         uiOutput('Option2a'), 
         uiOutput('Option3a') 
       ) 
    ) 
), 
    mainPanel(imageOutput('plot') 
) 
) 
)) 
s <- function(input, output) { 

    output$Option1 = renderUI({ 
    if (input$study == 'EX') { 

     selectInput('differ', label='Patient ID', 
        choices = c('013412-826-001-002','013412-840-001-001', 
           '013412-840-001-002', 
           '013412-840-001-003','013412-840-001-004')) 
    } 
    }) 
    output$plot <- renderImage({ 
    return(list(
     src = "./images/EXG.jpeg", 
     contentType = "image/jpeg", 
     alt = "Face" 
    )) 
    }, deleteFile = FALSE) 
} 
shinyApp(ui = u, server = s) 

产量: enter image description here

更新:

我在最后加了deleteFile=FALSE保持renderImage从每次运行时将其删除。不知道为什么它默认会这样做。

+0

OP的任何反馈? –