r - ETS model using Shiny -


im trying create web application new rstudio feature shiny. i'm trying ets state space model. want specify model type manually (bold text in server.r). i'm giving inputs within quotes in server.r. if give iputs within quotes not take. please me...

ui.r

library(shiny) shinyui(pagewithsidebar(   headerpanel( "forecast", "flowserve"),   sidebarpanel(     fileinput('file1', 'select csv file',               accept=c('text/csv')               ),     checkboxinput('header', 'header', true),     radiobuttons('sep', 'separator',                  c(comma=',', semicolon=';', tab='\t')                  ),     tags$hr(),     numericinput("startyear", "start year , month",2010),     sliderinput("month","",min=1, max=12,value=1, step=1, animate=t),      tags$hr(),     selectinput("error", "error type", list("multiplicative"="m","additive"="a")),     selectinput("trend", "trend type", list("multiplicative"="m","additive"="a", "null"="n")),     selectinput("seasonal", "seasonal type", list("multiplicative"="m","additive"="a", "null"="n")),   submitbutton("update")   ),    mainpanel(      tabsetpanel(     tabpanel("data", tableoutput('contents')),     tabpanel("time plot",  plotoutput('tsplot')),     tabpanel("forecast",  plotoutput('plotforecast'))             )     ) )) 

server.r

library(shiny) library(forecast) shinyserver(function(input,output){    data1 = reactive({   infile<-input$file1   if(is.null(infile))     return(null)   read.csv(infile$datapath, header=input$header, sep=input$sep)   }) output$plotforecast<-renderplot(function(){   datats<-ts(data1(), start=c(input$startyear,input$month), frequency=12)   model<-ets(datats, model="input$error input$trend input$seasonal")   fit1<-fitted(model)   future1<-forecast(model, h=4, level=c(95,97.5))     p2<-plot.forecast(future1,shadecols=c("yellow","orange"), xlab=expression(bold(year)), ylab=expression(bold(demand)))   print(p2)   }) 

you should replace model<-ets(datats, **model="input$error input$trend input$seasonal"**) model<-ets(datats, model=paste0(input$error, input$trend, input$seasonal)) because model argument expect 3-letter-string. paste0 concatenates character vectors (see ?paste0 details).


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -