Monday, 31 January 2022

Dynamically load data into rmarkdown html output

Is there a way to have the data associated with and html output file generated via Rmarkdown be loaded dynamically (e.g., via javascript or ajax) when opening the html output?

For instance, I have this simple Rmarkdown file which produces a plot (in svg) and a table:

---
title: "test"
output: 
    html_document:
        self_contained: false
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(dev = "svglite", fig.ext = ".svg")
library(svglite)
library(DT)
```

```{r, echo=FALSE}
DATA <- data.frame(a = 1:5, b = 6:10)
plot(DATA)
datatable(DATA)
```

Is there a way to feed the data to the html file so that when the data changes and I open it again the plot and table are updated automatically without having to render the Rmarkdown script?



from Dynamically load data into rmarkdown html output

No comments:

Post a Comment