Dynamic shiny with data from web


#1

I would like to make a shiny app to explore data from website, but when i lunch my app i get error “object of type ‘closure’ is not subsettable”.

the data here come from the european central bank via the package “ecb” which connect to their API and get the data wanted. Here my code :

UI

library(shiny)
#library(quantmod)
library(lubridate)
library(plotly)
library(ecb)
library(ggplot2)

ti<-c(“PIB”,“MM_M3”,“Taux_d_Inflation”)
data<-data.frame(“ICP.M.U2.N.000000.4.ANR”,“BSI.M.U2.Y.V.M30.X.I.U2.2300.Z01.A”,“MNA.Q.Y.I8.W2.S1.S1.B.B1GQ._Z._Z._Z.EUR.LR.GY”)
colnames(data)<-ti

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

#Application title
titlePanel(“Evolution Economique”),

#Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
h1(“Indicateur Europe”),
selectInput(“chiffre”,“Indicateur:”,
choice=ti),
#downloadButton(“downloadData”, “Download”),
actionButton(“go”,“Load”),
hr(),
helpText(“Donnees Banque Centrale Europeenne”)
),

#Show a plot of the generated distribution
mainPanel(
  plotlyOutput("graph")
)

)
))

Server

library(shiny)
library(lubridate)
library(plotly)
library(ggplot2)
library(ecb)

#dataset<-function(indice){
#compa<-indice
#compa<-as.character(compa)
#temp<-data[[compa]]
#temp<-as.character(temp)
#temp<-data.frame(Date=ymd(as.character(get_data(temp)$obstime),"%Y-%m"),Valeur=get_data(temp)$obsvalue)
#dataset<-get_data(indice)
#dataset<-data.frame(Date=dataset$obstime,Valeur=dataset$obsvalue)
#dataset
#}

#Define server logic required to draw a histogram
shinyServer(function(input, output) {

#handlerExpr,observeEvent,eventExpr
#temp<-eventReactive(input[[“go”]], handlerExpr = {
#temp<-dataset(input$chiffre)
#temp
#})
temp <- eventReactive(input$go,{
#req(input$chiffre)
compa<-input$chiffre
compa<-as.character(compa)
compa<-data[[compa]]
compa<-as.character(compa)
#temp<-data.frame(Date=ymd(as.character(get_data(compa)$obstime),"%Y-%m"),Valeur=get_data(compa)$obsvalue)
temp<-get_data(compa)
temp<-data.frame(Date=ymd(as.character(temp$obstime),"%Y-%m"),Valeur=temp$obsvalue)
temp
})

output$graph <- renderPlotly({
plot_ly(temp(),x=~Date,
y=~Valeur,type=“scatter”,mode=“lines”)
#layout(title=“Quaterly evolution”)
})

})

as you can see, i tried a lot of thing ^^, thank for some help