相关疑难解决方法(0)

在闪亮的应用程序中嵌入图像

我一直在研究一个闪亮的应用程序,并希望在应用程序的右上角包含一个徽标.如何使用闪亮和r轻松嵌入图像?

谢谢!ķ

embed r shiny

46
推荐指数
2
解决办法
6万
查看次数

如何将图像放在R Shiny标题中

所以我使用的是R Shiny,我想在标题的文本右侧放置一个图像.我似乎可以将图像放在应用程序的任何位置,但标题旁边除外.你能不把图像放在titlePanel()功能中吗?这是我正在使用的代码片段:

library(shiny)

# Define UI for random distribution application 
shinyUI(fluidPage(#theme="bootstrap.css",

  # Application title
  titlePanel("My Title",img(src = "picture.jpg", height = 50, width = 100)),
  sidebarLayout(
    sidebarPanel(
Run Code Online (Sandbox Code Playgroud)

因此,当我使用上面的代码时,我似乎无法在应用程序的任何位置看到我的图像....

r shiny

9
推荐指数
1
解决办法
1万
查看次数

将带有html的本地图像添加到Shiny应用程序中

我正在尝试添加位于我的计算机上的图像,但它无法正常工作.我创建了一个test.html文件,当我用浏览器(firefox)打开它时,它会渲染图像.但是当我尝试使用与Shiny相同的代码时,它不起作用.以下是我正在尝试的代码:

#html Code
<!DOCTYPE html>

<html>
<head>
    <title>
    Corinthians
    </title>
</head>
<body>
           <p>
               Vai corinthians
        </p> 

      <img id="stats_logo" align="right" src="file:///H://lab/comunicacao/logo hyper/logo_hyp.jpg" />   

  </body>

</html>

## Shiny Code
headerPanel_2(
HTML(
'<div id="stats_header">
                    Relatório de Horas
                    <a href="http://hyperativa.com.br/" target="_blank">
                    <img id="stats_logo" align="right" alt="" src="file:///H://lab/comunicacao/logo hyper/logo_hyp.jpg" />
                    </a>
                    </div>'
), h3, "Relatório de Horas"
)
Run Code Online (Sandbox Code Playgroud)

这是functionm,headerPanel_2.我正在使用:

headerPanel_2 <- function(title, h, windowTitle=title) {    
  tagList(
    tags$head(tags$title(windowTitle)),
   h(title)
  )
}
Run Code Online (Sandbox Code Playgroud)

我认为,代码中的关键是"src ="file:/// H:// lab/comunicacao/logo hyper/logo_hyp.jpg".那有什么问题?我怎么说闪亮在哪里?该文件位于我的电脑上?

r shiny

8
推荐指数
1
解决办法
8698
查看次数

UI侧的R Shiny img()不会渲染图像

我在Shiny UI中尝试渲染的本地文件夹中有一个静态图像,但它不起作用.显示中间带有问号的损坏图像.

ui <- fluidPage(img(src = 'imagefile.png', height = '100px', width = '100px'))
server <- function(input, output) {}
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)

知道发生了什么事吗?

r shiny

4
推荐指数
1
解决办法
5591
查看次数

在闪亮的 R 中显示来自网络的图像

我正在尝试制作一个从 Nasa API 检索图像并将其显示给用户的 Shiny 应用程序。尽管我设法从 API 下载图像并将其存储在临时文件中,但我无法在闪亮的应用程序中显示它,而只能在本地显示。到目前为止,这是我的代码:

library(shiny)
library(httr)
library(jpeg)
library(RCurl)
library(jsonlite)
library(shinythemes)
#library(imager)

key<-"eH45R9w40U4mHE79ErvPWMtaANJlDwNaEtGx3vLF"
url<-"https://api.nasa.gov/planetary/apod?date="


ui <- fluidPage(theme = shinytheme("yeti"),

   # Application title
   titlePanel("Nasa API"),


   sidebarLayout(
      sidebarPanel(
        helpText("Wellcome to Nasa search API ",
                            "enter a date in YYYY-MM-DD to search for picture"),
                   textInput("date", label="Date input", 
                             value = "Enter date..."),
                   actionButton("go", "Search")
      ),


      mainPanel(
        imageOutput("myImage")
      )
   )
)


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

  query<-eventReactive(input$go,{
    input$date
    })


  output$myImage <- renderImage({
    nasa_url<-paste0(url,query(),"&api_key=",key)
    # A temp file to save the output.
    # …
Run Code Online (Sandbox Code Playgroud)

r shiny

3
推荐指数
1
解决办法
2969
查看次数

没有img(src())的闪亮应用程序中的本地图像?

我想按照以下说明在我的闪亮应用程序中包含一个本地图像文件:

在有光泽的应用程序中嵌入图像

但是,由于某种原因,我的IT网络安全性阻止了R读取该图像。

  • 我可以确认这是IT安全的障碍,因为当我移至另一台计算机时,可以使用相同的确切代码和文件/目录结构。
  • 这也很奇怪,因为我能够从该文件夹中读取其他文件,因为其他命令(例如)read.csv()未被阻止。我不知道内部执行了哪些子例程,img(src())但是我的网络不喜欢它。

有其他方法可以将图像嵌入闪亮的应用程序ui中吗?

r shiny

1
推荐指数
1
解决办法
1367
查看次数

标签 统计

r ×6

shiny ×6

embed ×1