Hi, I have a shinyapp, in which there are two tables that are generated with rhandsontable package. table_1 (hot) is totally independent of table_2 (hot2), but in table_2 there are some columns that are calculated from user inputs (in table_2) and the values from table_1 (like column F in the below example). In table_1, user should be able to insert or remove rows (one row or multiple rows). How can I remove the same rows in table_2, that the user has just removed in table_1?
As an example, In this code:
library(shiny)
library(rhandsontable)
library(dplyr)
ui <- fluidPage(
h3("table_1"),
rHandsontableOutput("hot"),
br(),
h3("table_2"),
rHandsontableOutput("hot2")
)
server <- function(input, output, session) {
dat <- data.frame(A = c(1:5), B = c(5:1))
dat2 <- data.frame(C = c(4:8), D = c(10:14), E = c(6:10))
dat2 <- mutate(dat2, F = dat2$D + dat$A)
output$hot <- renderRHandsontable(rhandsontable(dat))
output$hot2 <- renderRHandsontable(rhandsontable(dat2))
observeEvent({
input$hot
input$hot2
}, {
dat <- hot_to_r(input$hot)
dat2 <- hot_to_r(input$hot2)
dat2 <- mutate(dat2, F = dat2$D + dat$A)
output$hot <- renderRHandsontable(rhandsontable(dat) %>%
hot_context_menu(allowColEdit = F))
output$hot2 <- renderRHandsontable(rhandsontable(dat2) %>%
hot_context_menu(allowRowEdit = F, allowColEdit = F) %>%
hot_col(col = "F", readOnly = T))
})
}
shinyApp(ui, server)
If I select rows 2 and 4 of table_1 and remove them, how can the same rows in table_2 get removed? Is it possible to find out which rows are removed?