2016-03-15 97 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的任何反饋? –