-->

How to add a new row to uploaded datatable in shin

2019-03-01 09:59发布

问题:

I would like to design a basic production planning features. Mainly, i try to do in shiny what i do in excel. I have a file that is uploaded by user. Then, user should adjust new quantity(s) which decreases the inventory level. -in one day, multiple adjustments- *Day is taken from system date. * The new lines should be displayed. here is the sample data : http://www.filedropper.com/data2_2

library(shiny)

shinyServer(function(input, output) {

  output$table1 <- renderTable({

    if (is.null(input$file1))
      return(NULL)
    read.csv(input$file1$datapath, header=TRUE, sep=";",
             quote='')

    })

  addData <- observe({
    if(input$action > 0) {
      f (is.null(input$file1))
      return(NULL)
      read.csv(input$file1$datapath, header=TRUE, sep=";",
               quote='')

      `uploadedfile1` <- read.csv(input$file1$datapath, sep=";")
      uploadedfile2 <- uploadedfile1

      safetystock <- 585

      newLine <- isolate(c(Sys.Date(), "provided by file", input$spotQuantity, inventory, safetystock, Location2))

      isolate(uploadedfile2Plot <- rbind(as.matrix(uploadedfile2), unlist(newLine)))
      uploadedfile2 Plot
    }
  })
  })


shinyUI(fluidPage(

  sidebarLayout(
    sidebarPanel(

      fileInput('file1', 'Choose File', accept=c('text/csv', 'text/comma-separated-values,text/plain', '.csv')),
      numericInput("Quantity", "Enter Quantity",value=0),
      actionButton("action","Confirm")
    ),

    # Show a plot of the generated distribution
    mainPanel(
      tableOutput("table1")

    )
  )
))