I have created an .qmd
file in R which contains a table created using the excellent reactable package.
How can I change the data contained in this table using only javascript?
I know that something similar can be done using crosstalk or shiny, but I want to know specifically how to do this using only javascript.
Here is a example .qmd
reprex that describes the problem:
---
title: "update reactable"
format: html
---
```{r}
library(reactable)
ojs_define(iris1 = iris[1:5,],
iris2 = iris[51:52,],
iris3 = iris[101:104,])
reactable(iris[1:5,],
elementId = 'iris')
```
```{ojs}
viewof choice = Inputs.radio(['a','b','c'], {label: 'choose a dataset', value: 'a'})
```
```{ojs}
datasets = ({'a': iris1,
'b': iris2,
'c': iris3
})
dataset = datasets[ choice];
dataset
```
```{ojs}
"update reactable instance based on user's choice here"
// update reactable instance based on user's choice here
```
Thanks