首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >includeHTML用于闪亮,shinyApps.IO和Dropbox

includeHTML用于闪亮,shinyApps.IO和Dropbox
EN

Stack Overflow用户
提问于 2014-10-19 03:54:03
回答 1查看 1.2K关注 0票数 3

晚上好,

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

我想有一个HTML文件驻留在我的Dropbox帐户,并包括它到一个闪亮的应用程序使用includeHTML。这样做的主要原因是,我的本地机器有一个进程来更新HTML (它是使用shinyApps.IO生成的),如果我可以从访问它,我就不必每次更新它时都上传它。

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

代码语言:javascript
复制
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文件执行同样的操作,然后使用includeHTML在一个闪亮的应用程序中显示该文件。有人知道如何做到这一点吗?

任何建议都将不胜感激,

菲利普

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-20 12:49:04

下面是一个演示将dropbox添加到一个闪亮应用程序的最小示例。关键点是设置content(request, as="text")并将向量呈现为文本。

代码语言:javascript
复制
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

代码语言:javascript
复制
require(shiny)

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

server.R

代码语言:javascript
复制
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})
})
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26447118

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档