0
我開始構建我的第一個閃亮應用程序,並且結果比預期更復雜(學習!) 。不幸的是,我設法讓谷歌把大量的小錯誤轉化爲沒有錯誤的情況,它只是返回一張空白圖表。R Shiny:如何從「日期範圍」中獲取日期,將它們插入到Quandl中,並使用生成的數據生成圖表
守則:(服務器)
library(ggplot2)
library(Quandl)
library(methods)
shinyServer(
function(input, output) {
# see (https://stackoverflow.com/questions/22834778/r-shiny-daterangeinput-format)
start_date2<-reactive({format(input$date_range[1])})
end_date2<-reactive({format(input$date_range[2])})
psuedonym<-data.frame(Date=as.Date(character()),
Value=integer(),
stringsAsFactors=FALSE)
psuedonym<-reactive({Quandl("ZILL/Z94550_A", start_date2, end_date2, type="raw")})
output$qplot<-renderPlot({reactive({plot(psuedonym$Date, psuedonym$Value)})})
})
(UI)
library(shiny)
shinyUI(fluidPage(
titlePanel("My Shiny App"),
sidebarLayout(position="right",
sidebarPanel(
plotOutput("qplot")
),
mainPanel(dateRangeInput("date_range",
label=h3("Date Range"), start="2010-01-01", end="2015-01-01",
)
))))
我想要什麼:我希望用戶能夠輸入日期,日期範圍,輸入這些變量成Quandl代碼(https://www.quandl.com/help/r),然後爲它們提取數據並生成一個簡單的圖形。稍後我想添加定義郵政編碼和變量的功能。這一點,例如,工作原理:
library(ggplot2)
library(Quandl)
library(methods)
shinyServer(
function(input, output) {
start_date="2010-01-01"
end_date="2015-01-01"
psuedonym=Quandl("ZILL/Z90001_A", start_date, end_date, type="raw")
output$qplot<-renderPlot({plot(psuedonym)})
我覺得是哪裏錯了:這(R: error in qplot from ggplot2: argument "env" is missing, with no default)和以前的錯誤消息,讓我覺得這事出了毛病的數據幀,它沒有得到Quandl數據不知何故。
在此先感謝您的幫助
哇,我絕對不知道如何閃亮的作品。我會再次閱讀教程。謝謝! – William