r - 闪亮的 img() 函数,我如何让图像出现?
问题描述
我正在尝试使用 Shiny,但我的 img() 函数不起作用。我已将它放在www
包含我的app.R
文件的文件夹中的目录调用中,并尝试同时使用 .jpg 和 .png 但图像没有出现。
我闪亮的应用程序的代码是
ui <- fluidPage(
titlePanel("Customers"),
sidebarLayout(
sidebarPanel(
h1("Choose Dataset"),
br(),
br(),
br(),
br(),
br(),
img(scr = "Logo.jpg", height = 100, width = 150)),
mainPanel(
h1("Results"),
p("The results are as follows")
)
)
)
# Define server logic ----
server <- function(input, output) {
}
# Run the app ----
shinyApp(ui = ui, server = server)
我还尝试了其他建议使用runApp
它的答案也没有奏效。
谁能帮忙解释为什么图像不想出现?
我现在收到以下错误:
Warning in pngfun(filename = filename, width = width, height = height, res = res, :
unable to allocate bitmap
Warning in pngfun(filename = filename, width = width, height = height, res = res, :
opening device failed
Warning: Error in pngfun: unable to start png() device
[No stack trace available]
谢谢
解决方案
你有一个小错字(scr 而不是 src)......试试这个:
img(src = "Logo.jpg", height = 100, width = 150))
如果 Logo.jpg 在 www/ 中,它应该可以工作
推荐阅读
- java - 无法自动装配 javamailSender
- swift - 无法将图像从 url 加载到 Swift 中的 UICollectionViewCell
- c++ - 构造后更改指针的地址
- python-3.x - Python 随机 BPF
- sass - 如何在 sass 中正确显示我的项目网格?我的图像没有形成 3 行网格
- java - 使用 Java 标准功能拦截整个类
- typescript - 如何转换
> 进入TaskEither 在 fp-ts - c# - 试图在数据网格列中显示数据库中的图像异常“找不到组件”
- sql - DBMS 中基于投票的审批系统
- python - PyQt5 不更新 TextEdit 和 Label Text