包括用于闪亮、shinyApps.IO和Dropbox的超文本标记语言 [英] includeHTML for shiny, shinyApps.IO and Dropbox

查看:15
本文介绍了包括用于闪亮、shinyApps.IO和Dropbox的超文本标记语言的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好,

快速问题,与shinyApps.IO上托管的R/Shiny应用程序相关。

我希望在我的Dropbox帐户上有一个HTML文件,并将其包含到一个使用cluddeHTML的闪亮应用程序中。这样做的主要原因是,我的本地计算机有一个进程来更新HTML文件(该文件是使用CONTER生成的),如果我可以从shinyApps.IO访问它,我就不必在每次更新它时都上载它。

现在,可以使用以下命令序列读入Dropbox上的RData文件:

load("my_dropbox_credentials.rdata") # assume that file exists
file.InputData <- "https://www.dropbox.com/s/SOMEDROPBOXCODE?dl=0"
data.input     <- (GET(url = file.InputData))
load(rawConnection(data.input$content))

这将从Dropbox加载RData数据文件,并且它也适用于shinyApps.IO。

现在,假设我想对一个HTML文件做同样的事情,然后在一个闪亮的应用程序中使用cluddeHTML显示它。有人知道如何做到这一点吗?

如有任何建议,我们将不胜感激。

Philipp

推荐答案

这里是一个最小的示例,演示如何将Dropbox html添加到一个闪亮的应用程序中。关键是设置content(request, as="text")并将向量渲染为文本。

require(shiny)
require(httr)

request <- GET(url="https://dl.dropboxusercontent.com/s/rb0cnyfiz2fgdaw/hello.html")
dropbox.html <-content(request, as="text")

runApp(
  list(
    ui = fluidPage(
      titlePanel("Dropbox HTML file"),
      mainPanel(
        htmlOutput("includeHTML")
        )
      ),
    server = function(input, output){
      output$includeHTML <- renderText({dropbox.html})
    }
    )
  )

分隔uI.R和server.R

ui.R

require(shiny)

shinyUI = fluidPage(
  titlePanel("Dropbox HTML file"),
  mainPanel(
    htmlOutput("includeHTML")
  )
)

服务器.R

require(shiny)
require(httr)

request <- GET(url="https://dl.dropboxusercontent.com/s/rb0cnyfiz2fgdaw/hello.html")
dropbox.html <-content(request, as="text")

shinyServer(function(input, output){
  output$includeHTML <- renderText({dropbox.html})
})

这篇关于包括用于闪亮、shinyApps.IO和Dropbox的超文本标记语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆