2016-04-24 64 views
2

我在Shiny应用程序中显示图像时遇到问题。代码保存在桌面,我也有一个logo.png的www文件夹。我也将工作目录设置为桌面:图像不显示RShiny

library(shiny) 
library(png) 

ui <- fluidPage(
    img(src="logo.png", height = 400, width = 400) 
) #close fluidpage 


server <- function(input, output, session){ 

} # closer server 

shinyApp(ui=ui, server=server) 

下面是输出结果的外观。
enter image description here

我更喜欢在同一个文件中有服务器和用户界面以便于理解。也许这就是问题所在?

+0

如果您在浏览器中打开它,它会显示吗? – SymbolixAU

+0

不,它不.. –

+0

这很奇怪。我尝试拆分server.R&ui.R,并[文档/指南](http://shiny.rstudio.com/tutorial/lesson2/)说这是如何完成的... – SymbolixAU

回答

0

如果你只是想显示你的图片。你可以在Rshiny上使用HTML。以下是修改后的代码,您可以尝试。希望工程

library(shiny) 
library(png) 

ui <- fluidPage(
headerPanel(
    list(tags$head(tags$style()), 
    HTML('<img src="logo.png", height="400px"  
      style="float:right"/>','<p style="color:black"></p>') 
     )#headerPanel closes 
     ) #close fluidpage 


     server <- function(input, output, session){ 

     } # closer server 

     shinyApp(ui=ui, server=server) 
1

类似闪亮img问题solved here。而不是直接或在控制台执行代码,创建一个正确格式的app.R并点击Run App似乎工作。