How to add a new row to uploaded datatable in shiny

情到浓时终转凉″ 提交于 2019-12-02 09:27:26

问题


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")

    )
  )
))

来源:https://stackoverflow.com/questions/34403004/how-to-add-a-new-row-to-uploaded-datatable-in-shiny

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!