【发布时间】:2014-11-07 03:30:36
【问题描述】:
我正在尝试创建一个闪亮的应用程序,该应用程序使用谷歌电子表格中的外部可用信息,我正在将其下载到临时 .csv 文件中。该应用程序在我的本地计算机上正常运行,但是当我尝试将其推送到 shinyapps.io 时,该应用程序失败了。我尝试使用一个简单的示例重新创建下面的错误。闪亮的应用程序可以在这里找到:https://n8sty.shinyapps.io/test/。我已经复制了下面本地工作的 server.R 和 ui.R 文件。
我认为问题在于服务器无法以与我的本地计算机相同的方式处理下载外部 google sheet 文件。有谁知道如何在闪亮的应用中使用谷歌文档?
ui.r
require(shiny)
shinyUI(fluidPage(
mainPanel(
tableOutput("table")
)
))
server.r
require(shiny)
td <- tempdir()
tf <- tempfile(pattern = 'test', tmpdir = td, fileext = '.csv')
url <- 'https://docs.google.com/spreadsheets/d/1c1ZI0P0ydunm-wc1eb3-jYbWfwMZQc4eAyWlHJut2wY/export?usp=sharing&format=csv'
download.file(url, tf, method = 'auto', quiet = TRUE)
df <- read.csv(tf)
shinyServer(function(input, output) {
output$table <- renderTable({
df
})
})
谢谢
【问题讨论】:
-
@MrFlick 似乎非常相关。感谢您的指点。如果有人想在答案上击败我,请随意。如果没有,我明天有机会再发。