我的计算机上有以下运行良好的应用程序,但是,在shinyapps上部署时会引发错误:
用户界面
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"))
))
)
))
服务器
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上的文件,因此我想使用该文件来自动更新图形和统计信息。使用网络数据的最佳方法是什么?
最佳答案
更换
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"))