Black Lives Matter. Please consider donating to Black Girls Code today.

Table with interactive variable

Hi,

I have a plotly table summarizing some data. I make some changes to the data prior to displaying it in the table, let’s say through a variable x. I would like the user to be able to change x interactively and see the resulting difference on the plotly table. For example if I have:

library(plotly)
data("mtcars")
x=1
mtcars$my_var=mtcars$mpg+x

t <- plot_ly(
  type = 'table',
  columnwidth = c(10, 10),
  columnorder = c(0, 1),
  header = list(
    values = c("Car","My Value"),
    align = c("center", "center")
  ),
  cells = list(
    values = rbind(rownames(mtcars), mtcars$my_var),
    align = c("center", "center")
  ))

t

and I would like the user to provide the value for x in a cell next to the plotly table.

I think this should be pretty easy, but I couldn’t find the way to do it.

Best Regards,
Mate