0

我正在尝试在 Shiny 上显示 R 生成的绘图图像。我的输出图像在 App-1\www 中。

使用主面板,我可以一张一张地显示图像。是否可以使用下拉菜单并从闪亮中调用图像?

有什么建议吗?

问候, 拉吉

4

1 回答 1

0

这对我来说就像一个黑客,但它有效。我也想知道这是否可以使用:

mainPanel(
  img(src="nestler_test.jpg", height = 700, width = 00)
)

也为这里的格式道歉....

用户界面

图书馆(闪亮)

定义用户界面

闪亮的UI(流体页面(

# 应用程序标题 titlePanel("示例"),

# 带有滑块数量的侧边栏 sidebarLayout( sidebarPanel( selectInput("stage", "example text:",choices = c("stage1", "2", "3")) ),

# Show a plot of the generated distribution
mainPanel(
  plotOutput("distPlot")
)

) ))

服务器.R

图书馆(JPEG)

定义服务器逻辑

闪亮服务器(功能(输入,输出){

输出$distPlot <- renderPlot({

if (input$stage=="stage1") {
  img=readJPEG('1st_test.jpg')
} else if (input$stage=='2') {
  img=readJPEG('2nd_test.jpg')
}
plot(c(100, 250), c(300, 550), type='n', ylab='',xlab='', xaxt='n', yaxt='n', frame.plot=F)
rasterImage(img, 100, 300, 250, 550)

}) })

于 2014-12-06T21:09:32.583 回答