Hello,
I am a Shiny App newbie. I have watched countless videos and read many forms to try to resolve my issue but not avail.
I am having an issue making a shiny app that allows user to upload his/her data set (CSV with 60 observations) and get a forecast, decomposition, seasonality, EOQ etc.
Issue lies with working with the uploaded data. As of now I have code to get data on shiny app. but it doesn't let me access it or says data only has 1 observation
Please help. It has been frustrating me for last 8-9 hours. issue sections in bold
library(tidyverse)
library(readxl)
library(readr)
library(tidyverse)
library(forecast)
library(knitr)
library(shiny)
Define UI for application that draws a histogram
shinyUI(fluidPage(
# Application title
titlePanel("Procurement Decision System"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
numericInput("startYR","Please enter start year:", " "),
numericInput("endYR","Please enter End year:", " "),
numericInput("s","Shipping Cost(USD):", " "),
numericInput("h", "How many months would you like to Forecast:", ""),
numericInput("H", "Holding Cost per unit (USD):", ""),
**fileInput("file", "Choose CSV File",**
** multiple = TRUE,**
** accept = c(".csv")),**
** # Input: Checkbox if file has header ----**
** checkboxInput("header", "Header", TRUE),**
** # Input: Select separator ----**
** radioButtons("sep", "Separator",**
** choices = c(Comma = ",",**
** Semicolon = ";",**
** Tab = "\t"),**
** selected = ",")**
** ),**
# Main panel for displaying outputs ----
mainPanel(
tableOutput("file1"),
plotOutput("Dcomp")
)
)
)
)
library(readxl)
library(readr)
library(tidyverse)
library(forecast)
library(knitr)
library(shiny)
shinyServer(function(input, output,session) {
File1 <- reactive({
req(input$file)
ext <- tools::file_ext(input$file$name)
switch(ext,
csv = vroom::vroom(input$file$datapath, delim= ","),
validate("invalid file"))
})
output$Dcomp <- renderPlot({ **
** req(input$file)
** #req(input$startYR)**
** QTY <- ts(File1,start = c(2017,1),frequency = 12)**
** Dcomp <- decompose(QTY)**
** })**
})
#code not done yet...