0

I want to implement aggregate function to my shiny application but I have big problem with making it work.

There is fragment of code responsible for file upload

  data <- reactive({
    file1 <- input$file
    if(is.null(file1)){return()} 
    dataSet <- read.table(file=file1$datapath, sep=input$sep, header = input$header, dec = input$dec )

    updateCheckboxGroupInput(session, "choices1", choices = colnames(dataSet))


    updateSelectInput(session, "combobox", choices = colnames(dataSet))
    updateSelectInput(session, "combobox1", choices = colnames(dataSet))
    updateSelectInput(session, "combobox2", choices = colnames(dataSet))
    updateSelectInput(session, "combobox3", choices = colnames(dataSet))
    updateSelectInput(session, "combobox4", choices = colnames(dataSet))
    dataSet
  })

Actually this code also updates other important widges in my application for example widget named "combobox" is used to select column to make histogram.

Widgets "combobox3" and "combobox4" are used for aggregate function

And there is fragment of code being responsible for aggregate

output$policz2 <- renderTable({
x <- data()


aggregate(x$input$combobox3, by=list( wartosc = x$input$combobox4), FUN=sum)
}) 

And of course when I upload file and try to do something with aggregate it always shows

"Error: no rows to aggregate"

What I must change with aggregate code to make it finally work as it should?

Cœur
  • 37,241
  • 25
  • 195
  • 267

0 Answers0