I'm working on a shiny dashboard app, where i'm trying to add new rows to a table when clicking a button. When clicking, data is gathered from multiple input elements, collected in a list, which is then added as a new row. However, while the row is added, all previous rows become 'NA'.
Server code:
RowList <- c()
dfRowList <<- data.frame(matrix(ncol = 13, nrow = 0))
colnames(dfRowList) <<- c(# list of row properties #)
observeEvent(input$AddRow, {
Newrow <- paste0("R", length(RowList) + 1)
RowList <<- append(RowList, NewRow)
RProps <- c()
RProps <- c(NewRow)
for (prop in c(# list of row properties #)){
Propvalue <- input[[paste0("R", prop)]]
RProps <- append(RProps, Propvalue)
}
dfRowList[length(RowList),] <- RProps
output$RowList <- renderTable(dfRowList)
})
When using rbind() no new rows are created, just the 1 row is replaced by the new values and the column names are screwed over :/
I checked all other values. Creation of new row names, properties and lists works fine. When i use View(dfRowList) to look at the dataframe itself, it also shows the same problem (so its not a rendering problem). So, only adding the row does not work.
Does someone know what's going on here?
Thanks a lot in advance!