r - Shinyapps 部署在本地计算机上工作时无法工作

标签 r shiny

我有以下应用程序在我的计算机上运行良好,但是,在 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 中的日志时,我发现我得到如下错误:

文件错误(文件,“rt”):不支持 https://URL

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

最佳答案

替换

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"))

关于r - Shinyapps 部署在本地计算机上工作时无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30264585/

相关文章:

r - 在R中将一列数据转换为三列

r - 制作一个将函数调用作为参数传递给可管道函数的函数。

R Shiny tabPanel 在单击时不会自动到达页面顶部

html - ShinyUI - 如何在流体行/列网格中添加垂直/水平线?

r - 如何将函数应用于嵌套列表?

sql - 如何根据时间戳和值查找同步ID

从估计中删除一些因子交互项

r - Shiny 的 tabsetPanel 不在多个选项卡中显示图

R Shiny : Edit the format of a table output

r - 如何让图像 iconMarker 适用于plotGoogleMaps R?