晚上好,
快速问题,相关的R/闪亮的应用程序,托管在shinyApps.IO上。
我想有一个HTML文件驻留在我的Dropbox帐户,并包括它到一个闪亮的应用程序使用includeHTML。这样做的主要原因是,我的本地机器有一个进程来更新HTML (它是使用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在一个闪亮的应用程序中显示该文件。有人知道如何做到这一点吗?
任何建议都将不胜感激,
菲利普
发布于 2014-10-20 12:49:04
下面是一个演示将dropbox添加到一个闪亮应用程序的最小示例。关键点是设置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})
})https://stackoverflow.com/questions/26447118
复制相似问题