You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running dq_render_handsontable with a reactive input that changes the number of columns, I get an error when I add too many columns.
In the reproducible example below, you can add columns with the drop down bar. When I add columns with the app, I get this error: Warning: Error in [[: subscript out of bounds
I noticed this problem is coming from the dq_render_handsontable function.
Below is a small segment of code from the dq_render_handsontable function. This part of the function is producing the error because it is running update_filters() without first adding filters for the new columns. I modified the code to add new filters to the list like so : filters <<- correct_filters(filters, shiny::isolate(dqv$full[, columns, drop = FALSE]))
This modification makes the app work.
else if (shiny::is.reactive(table_data)) {
shiny::observeEvent(table_data(), {
if (no_update) {
no_update <<- FALSE
}
else {
dqv$full <- as.data.frame(table_data())
# ----- I added the following 2 lines:
filters <<- correct_filters(filters, shiny::isolate(dqv$full[,
columns, drop = FALSE]))
# ----- end of addition
if (!is.null(filters)) {
update_filters(dqv$full[, columns, drop = FALSE],
filters, session)
}
}
}, ignoreInit = TRUE)
dqv$full <- as.data.frame(shiny::isolate(table_data()))
}
One issue with this mod is that it seems to make shiny::observeEvent(app_input[[id]], ...) run more frequently than it should.
I noticed that this observeEvent actually runs 2 + 2 * n times each time I update a cell in the table, where n is the number of times I update columns.
For example, if I add a column once (n=1), then try to edit a cell in the table, observeEvent(app_input[[id]], ...) will run twice and update dqv$full twice. Then it will run the observeEvent two more times, but the second two times nothing gets updated.
If I add another column so that (n=2), 2 + 2 * 2 = 4, so there will be 2 dqv$full update events (where the same data gets update twice. Then there will be 2 more observeEvents where dqv$full does not update. I assume !is.null(app_input[[id]]$changes$source is maybe NULL.
Do you know why this observeEvent runs more when I add more columns ? Also, do you think the way I fixed this bug is okay, or would you recommend something else?
The text was updated successfully, but these errors were encountered:
When running
dq_render_handsontable
with a reactive input that changes the number of columns, I get an error when I add too many columns.In the reproducible example below, you can add columns with the drop down bar. When I add columns with the app, I get this error:
Warning: Error in [[: subscript out of bounds
I noticed this problem is coming from the
dq_render_handsontable
function.Below is a small segment of code from the dq_render_handsontable function. This part of the function is producing the error because it is running
update_filters()
without first adding filters for the new columns. I modified the code to add new filters to the list like so :filters <<- correct_filters(filters, shiny::isolate(dqv$full[, columns, drop = FALSE]))
This modification makes the app work.
One issue with this mod is that it seems to make
shiny::observeEvent(app_input[[id]], ...)
run more frequently than it should.I noticed that this observeEvent actually runs
2 + 2 * n
times each time I update a cell in the table, wheren
is the number of times I update columns.For example, if I add a column once
(n=1)
, then try to edit a cell in the table,observeEvent(app_input[[id]], ...)
will run twice and updatedqv$full
twice. Then it will run the observeEvent two more times, but the second two times nothing gets updated.If I add another column so that
(n=2)
,2 + 2 * 2 = 4
, so there will be 2dqv$full
update events (where the same data gets update twice. Then there will be 2 more observeEvents wheredqv$full
does not update. I assume!is.null(app_input[[id]]$changes$source
is maybe NULL.Do you know why this observeEvent runs more when I add more columns ? Also, do you think the way I fixed this bug is okay, or would you recommend something else?
The text was updated successfully, but these errors were encountered: