I have a function which produces multiple tables, e.g. one a reactable, the other the simple printout of a dataframe.
When using the function in a quarto document and rendering it, the output of the reactable is omitted unless it comes last in the function.
Any idea what's going on? I assume it's related to the issue dealt with here, but I don't see how to overcome it.
Many thanks.
Below the code which should reproduce the issue in a qmd document.
---
title: "Untitled"
format: html
---
```{r}
#| echo: true
#| warning: false
library(tidyverse)
library(reactable)
```
Reactable first; not shown in output
```{r}
fn_cars <- function(my_data) {
my_data[1:5,] %>% reactable()
print(my_data[1:5,])
}
```
```{r}
fn_cars(my_data=mtcars)
```
Reactable last, shows in output.
```{r}
fn_cars <- function(my_data) {
print(my_data[1:5,])
my_data[1:5,] %>% reactable()
}
```
```{r}
fn_cars(my_data=mtcars)
```