...I would like to update multiple values of my dataframe using reactivevalues. But my code works when I specify only value change. Below is my code,
values <- reactiveValues(df_data = NULL)
ipldata <- reactive({
myfiles <- input$iplfile
data <- read_excel(myfiles$datapath, 1, col_names = FALSE)
data <- data.frame(data)
data <- data[grep("esd", as.character(data[,1])),]
data <- subset(data, data[,1]== input$modeltype)
endrow <- grep(pattern = "Model/Extraction boundary information", as.character(data[,2]))
data <- data[grep(pattern = 'Parameter|Instance Parameter', as.character(data[,2]))[1]:endrow,]
data[is.na(data)]<- " "
colnames(data) <- data[1,]
data <- data[-1,-1]
rownames(data) <- 1:nrow(data)
last <- nrow(data)
data <- data[-last,]
data[!(is.na(data[,1])|data[,1]==" "),]
values$df_data <- data
})
observeEvent(input$modeltype, {
values$df_data <- ipldata()
print(values$df_data)
})
#
observeEvent(input$ChangeValues, {
output$newvalue1 <- renderUI({
data <- ipldata()
textInput("newvalue1", paste0('New ',data[1,1]),data[1,5],'15%')
})
output$newvalue2 <- renderUI({
data <- ipldata()
textInput(paste0("newvalue2",data[2,1]), paste0('New ',data[2,1]),data[2,5],'15%')
})
output$newvalue3 <- renderUI({
data <- ipldata()
textInput(paste0("newvalue3",data[3,1]), paste0('New ',data[3,1]),data[3,5],'15%')
})
output$newvalue4 <- renderUI({
data <- ipldata()
textInput(paste0("newvalue4",data[4,1]), paste0('New ',data[4,1]),data[4,5],'15%')
})
})
observeEvent(input$save, {
isolate({
values$df_data[1,5] <- input$newvalue1
values$df_data[2,5] <- input$newvalue2
# values$df_data[3,5] <- input$newvalue3
# values$df_data[4,5] <- input$newvalue4
})
})
output$IPLTable <- renderTable(
values$df_data
#changedipldf
)
For simplicity I'm not attaching my ui code. In my observeevent with save button, I'm able to update when I use,
Non- working code
observeEvent(input$save, {
isolate({
values$df_data[1,5] <- input$newvalue1
values$df_data[2,5] <- input$newvalue1
})
})
Working code
observeEvent(input$save, {
isolate({
values$df_data[1,5] <- input$newvalue1
})
})
The difference between the working observe event and non-working event is being the no of dataframe values that I'm trying to update before I click the save button. Can someone explain if reactivevalues are supposed to work for multiple updates in a dataframe or what am I doing wrong with my current code