I have been trying the new quarto tool by Rstudio and it seems like I cannot do something that was doable in the older versions of the R Notebook or R Markdown alternatives.
I want to organise my workflow through several quarto documents (.qmd) and I want to generate the .html documents to share with people who are not R users. For example, let's suppose I have the following 4 documents:
- 01_DataProcessing.qmd
- 02_StatisticalAnalysis.qmd
- 03_Plots.qmd
- 04_Reports.qmd
In 01_DataProcessing.qmd I clean and organise all data to be used in the other three files. Therefore, the other three files depend on 01_DataProcessing.qmd, *01_DataProcessing.qmd has to be run firstly so the other files can run. Within Rstudio this works perfectly because all data in the environment is accessible to all .qmd files.
Nevertheless, when I want to generate the .hmtl files I have to "render" the .qmd files. Here is where I am finding problems. It seems like the rendering ignore all variables in the global environment (and all loaded libraries) and therefore it shows and error (Execution halted). It means that I can only work with stand-alone documents with all the code, something that might be problematic for large workflows.
Am I missing something? Do I have to change some of my settings? is there any workaround? How can I specify the .qmd to use all data available in the global environment?
Please note that with newest version of Rstudio changing to .rmd does not solve the problem since the behaviour is the same as with .qmd documents. Also, please not that in the past this was not the case.
Edit
To give a reproducible example, suppose in the first qmd
file 01_DataProcessing.qmd, I have created a data.frame TestData
and I want to use the TestData
in the 03_Plots.qmd file
01_DataProcessing.qmd
---
title: "01_DataProcessing"
format: html
editor: visual
---
```{r}
library(tidyverse)
library(magrittr)
TestData <- data.frame(
x = c(1, 2, 3, 4, 5, 6, 7),
y = c(1 ,2 ,3, 4, 5, 6, 7))
```
03_Plots.qmd
---
title: "03_Plots"
format: html
editor: visual
---
If you try to render the file the execution is halted because the object TestData is not found.
```{r}
plot(TestData$x, TestData$y)
```