图片没有在Shiny app R中显示 [英] Image not showing in Shiny app R
问题描述
我有一个想要嵌入我的闪亮应用程序的图像,并且已经阅读了尽可能多的关于如何操作的内容。虽然,当我运行我的代码时,我得到的只是一个蓝色问号。
I have an image i'd like to embed into my shiny app, and have read as much as I can find on how to do it. Although, all I get is a blue question mark when I run my code.
这是我在 fluidPage中添加的代码行
ui
command
This is the line of code I have added, within the fluidPage
ui
command
img(src="logo.png", align = "right",height='100px',width='400px')
我的图片已放置在项目目录文件夹中,并尝试在名为www的单独文件夹中(根据此处提供的建议)
My image has been placed in the project directory folder, as well as trying in a separate folder inside named www (as per suggestion given here)
编辑:以下语境中使用的代码:
Code used in the following context:
ui <- fluidPage(titlePanel("Test title"),
img(src="logo.png", align = "right",height='100px',width='400px'),
hr())
推荐答案
在回到这个问题之后,我发现解决方案是简单地格式化Shiny代码,命名为e R文件 app.R
,然后单击运行App
,而不是选择所有代码并在控制台中运行。
After coming back to this problem, I found that the solution is to simply format the Shiny code properly, by naming the R file app.R
, and clicking Run App
as opposed to selecting all of the code and running within the console.
不确定这会产生什么影响,为什么会有所不同,但是我做过的众多Shiny应用程序在执行此操作时都得到了解决。
Not sure how or why this makes a difference, but the numerous Shiny applications I have worked on since have all been resolved when doing this.
这篇关于图片没有在Shiny app R中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!