我使用imageOutput
功能将若干图像放入Shiny应用程序中,如下所示,但仅显示最后一张图像。这是因为imageOutput
仅限于一张图片吗?
# ui.R
library(shiny)
library(png)
library(DT)
shinyUI(navbarPage(
title = " Nanoproject",
# first panel , create table of the peaksTable dataframe
tabPanel('Peak Table' ,
dataTableOutput("table1")),
# second panel
tabPanel('Peak Images' ,
imageOutput("image1",width=100,height=100),
imageOutput("image2",width=100,height=100),
imageOutput("image3",width=100,height=100),
imageOutput("image4",width=100,height=100),
imageOutput("image5",width=100,height=100),
imageOutput("image6",width=100,height=100),
imageOutput("image7",width=100,height=100),
imageOutput("image8",width=100,height=100),
imageOutput("image9",width=100,height=100),
imageOutput("image10",width=100,height=100),
imageOutput("image11",width=100,height=100)
),
# third panel
tabPanel('Event Table' , dataTableOutput("table3")),
# fourth panel
tabPanel('Event Images')
))
#server.R
# the peak images, 1-12
output$image1 <- renderImage({list(src=paste0(imagePath,"/peak1.png"))},deleteFile=FALSE)
output$image2 <- renderImage({list(src=paste0(imagePath,"/peak2.png"))},deleteFile=FALSE)
output$image3 <- renderImage({list(src=paste0(imagePath,"/peak3.png"))},deleteFile=FALSE)
output$image4 <- renderImage({list(src=paste0(imagePath,"/peak4.png"))},deleteFile=FALSE)
output$image5 <- renderImage({list(src=paste0(imagePath,"/peak5.png"))},deleteFile=FALSE)
output$image6 <- renderImage({list(src=paste0(imagePath,"/peak6.png"))},deleteFile=FALSE)
output$image7 <- renderImage({list(src=paste0(imagePath,"/peak7.png"))},deleteFile=FALSE)
output$image8 <- renderImage({list(src=paste0(imagePath,"/peak8.png"))},deleteFile=FALSE)
output$image9 <- renderImage({list(src=paste0(imagePath,"/peak9.png"))},deleteFile=FALSE)
output$image10 <- renderImage({list(src=paste0(imagePath,"/peak10.png"))},deleteFile=FALSE)
output$image11 <- renderImage({list(src=paste0(imagePath,"/peak11.png"))},deleteFile=FALSE)
但是,只加载最后图像
答案 0 :(得分:2)
图像文件的实际大小是多少?
我尝试了以下代码(filename1,filename2,filename3只是图像文件的一些本地路径名),并且在图像尺寸较小且不工作(呈现重叠方式)的情况下,它可以正常工作尺寸非常大。它看起来只有最后一个图像被渲染,但现实是所有其他图像都被隐藏在下面。
library(shiny)
ui <- fluidPage('Peak Images',
imageOutput("image1"),
imageOutput("image2"),
imageOutput("image3"))
server <- function(input, output) {
output$image1 <- renderImage({
list(src = filename1)
}, deleteFile = FALSE)
output$image2 <- renderImage({
list(src = filename2)
}, deleteFile = FALSE)
output$image3 <- renderImage({
list(src = filename3)
}, deleteFile = FALSE)
}
shinyApp(ui = ui, server = server)
答案 1 :(得分:0)
高度和宽度设置为“自动”,这解决了问题。感谢用户3949008让我意识到需要改变的高度和宽度。