[英]includeHTML for shiny, shinyApps.IO and Dropbox
晚上好,
關於R / shiny應用程序的快速問題,托管在shinyApps.IO上。
我想在我的Dropbox帳戶中放置一個HTML文件,並使用includeHTML將其包含在一個閃亮的應用程序中。 這樣做的主要原因是我有一個本地機器的進程來更新HTML文件(使用knitr生成),如果我可以從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文件做同樣的事情,然后在一個閃亮的應用程序中使用includeHTML顯示。 有誰知道如何做到這一點?
任何意見,將不勝感激,
菲利普
這是一個最小的示例,演示了如何將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")
)
)
server.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})
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.