如何从闪亮的上传文件中获取数据文件

时间:2019-05-16 16:18:54

标签: r shiny forecasting

我已将文件上传到闪亮的应用程序中以进行预测,我能够     使用Arima模型进行预测并且无法打印预测点     在闪亮的应用程序中。

ui.R

library(shiny) shinyUI(fluidPage(   titlePanel("DDDDDD"),  
sidebarLayout(
    sidebarPanel(    fileInput('TextFile', 'Choose Text file to upload',
                accept = c(
                  'text/csv',
                  'text/comma-separated-values',
                  'text/tab-separated-values',
                  'text/plain'
                )
      ),
      tags$hr(),
      h5(helpText("Select the read.table parameters below")),
      checkboxInput(inputId = 'header', label = 'Header', value = TRUE),
      checkboxInput(inputId = "stringAsFactors", "stringAsFactors", FALSE),
      tags$hr(),
      br(),
      selectInput("sep", "Seperator", choices = c(Comma=',',Semicolon=';',Tab='\t', Space=''), selected = ','),
      #radioButtons('skipper', 'Lines to skip',
      # c(Zero=0,
      #  One=1
      # ))
      tags$hr(),
      numericInput('year','Enter Starting Year',value =2018 ),
      tags$hr(),
      numericInput('month','Enter Starting month',value=01),
      tags$hr(),
      numericInput('frequency','Enter Frequency',value=12),

      downloadButton(outputId="downloadData",label = "DownloadData")  
    ),


    mainPanel(
      tabsetPanel(type="tab", 
                  #tabPanel("Input File Object DF ", tableOutput("filedf"), tableOutput("filedf2")),
                 # tabPanel("Input File Object Structure",verbatimTextOutput("fileob")),
                  tabPanel("ARIMA",plotOutput("contents1"), plotOutput("contents2")),
                 tabPanel("Summary", textOutput("sum")),
                tabPanel("Table",dataTableOutput("mytable1"))          

      ),

      tags$style(type="text/css",
                 ".shiny-output-error { visibility: hidden; }",
                 ".shiny-output-error:before { visibility: hidden; }"
      )



      #splitLayout(cellWidths = c("50%", "50%"), 

    )) ) )

#server.R library(shiny) library(forecast) library(DT) shinyServer(function(input, output) {
    #ARIMA Data   data_l<-reactive({
    inFile <- input$TextFile
    if (is.null(inFile))
      return(NULL)
    data<-ts(scan(inFile$datapath,skip=input$skipper),start=c(input$year,input$month),
             frequency = input$frequency)
    return(data)   })

     # Formulation for finding ARIIMA plot   output$contents1 <- renderPlot({
    data<-data_l()
    M2=auto.arima(data)
    M2F=forecast(M2,h=12)
    plot(M2F,main="ARIMA Forecast")
       })   output$contents2 <- renderPlot({
    data<-data_l()
    tsdisplay(diff(data,lag=1,differences = 1),lag.max=12,main="Is Data Stationary?")  })
     output$mytable1 <- DT::renderDataTable({
    DT::datatable(data[, input$show_vars, drop = FALSE])   })    })`enter code here`

我希望将预测点打印到不同的选项卡中,     想要在“数据集”标签上获取原始数据。

0 个答案:

没有答案