【问题标题】:Shinyapps deployment not working while works on local computer在本地计算机上工作时,Shinyapps 部署不起作用
【发布时间】:2015-05-15 16:37:11
【问题描述】:

我有以下应用程序在我的计算机上运行良好,但是,在 Shinyapps 上部署时它会引发错误:

ui.R

library(shiny)
library(ggplot2)
library(dplyr)
library(rCharts)
library(DT)
library(htmlwidgets)
library(shinyapps)
# dataset <- ntctidecombined

# Define UI for application that draws a histogram
shinyUI(fluidPage(

  # Application title
  titlePanel("Seattle Society fund raise"),

  # Sidebar with a slider 
  sidebarLayout(position="left",
                sidebarPanel( 

                ),
                mainPanel(
                  #       plotOutput('plot', height="700px"))

                  tabsetPanel(
                    tabPanel("Plot", plotOutput("plot", width = "500px", height = "600px")),
                    tabPanel("Donors / Ticket buyers", tableOutput("donors")),
                    tabPanel("Table", tableOutput("table"))
                  ))

  )
))

服务器.R

library(shiny)
library(ggplot2)
library(dplyr)
library(rCharts)
library(DT)
library(htmlwidgets)
library(shinyapps)

shinyServer(function(input, output) {

  #dataset <- load("ntctidecombined.Rda")
  dataset <- read.csv("https://dl.dropboxusercontent.com/u/9267938/Testspreadsheet.csv")

  dataset1 <- dataset %>% group_by(Category) %>% summarize(Sum = sum(Amount))

  output$plot <- renderPlot({
    dataset2 <- dataset1

  p1 <- ggplot(dataset1, aes(x = Category, y = Sum, fill = Category)) + 
  geom_bar(stat= "identity") + ylab("Total Amount (dollars)") +
  geom_text(aes(Category, Sum, label = Sum, vjust = -1.5)) + 
  coord_cartesian(ylim = c(0,10000))
  p1  

  })

   output$table <- renderTable(dataset1)
   output$donors <- renderTable(dataset)

})

当我检查shinyapps中的日志时,我发现我收到了如下错误:

Error in file(file, "rt") : https:// URLs are not supported.

我正在尝试使用 Dropbox 上的文件,因此我想使用该文件自动更新图表和统计信息。使用网络数据的最佳方式是什么?

【问题讨论】:

  • ?read.csv 开始并点击指向?url 的链接将我引向此:“请注意,除Windows 外,不支持https:// URL 方案。”。
  • 文档继续建议使用 download.fileRCurl 包。
  • 感谢 joran 的有用建议。我没有在 linux 机器上使用过 R,所以这可能是问题所在。
  • 您还可以查看 httr,它是一个 Hadley 包,其中包含 RCurl 的许多功能。
  • Joran:实际上我确实最终使用了httr 包,并且似乎可以无缝地工作。谢谢你。该应用程序正在运行jdevkota.shinyapps.io/seattle

标签: r shiny


【解决方案1】:

替换

dataset <- read.csv("https://dl.dropboxusercontent.com/u/9267938/Testspreadsheet.csv")

library(RCurl)
data <- getURL("https://dl.dropboxusercontent.com/u/9267938/Testspreadsheet.csv")
dataset <- read.csv(text = data )

应该可以。

或一行

dataset  <- read.csv(text=getURL("https://dl.dropboxusercontent.com/u/9267938/Testspreadsheet.csv"))

【讨论】:

    【解决方案2】:

    为 Dropbox 文件传递​​给 GetURL 的 URL 必须在哪里

    https://dl.dropboxusercontent.com/<string for user's file.csv>
    

    例如/u/9267938/File.csv

    【讨论】:

    • 不是仅提供链接的答案。
    猜你喜欢
    • 2013-02-12
    • 2020-08-25
    • 1970-01-01
    • 2023-01-11
    • 2023-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-22
    相关资源
    最近更新 更多