1

I am trying to write a report in Quarto using data loaded and processed using the Projecttemplate package's structure (http://projecttemplate.net/index.html).

Until a few weeks ago I could use the classic Projecttemplate load.project() function in my first code chunk to load the project and all data (including loading libraries, munging, caching and so on).

I could then add other chunks for making plots etc. based on the loaded data, and everything was working smoothly when rendering in any format (I successfully rendered html, pdf and docx documents).

Since last week, everything works fine if I just run each code chunk manually - I can load the Projecttemplate project (including all the automatic munging and other processing steps which I set up for it), run analyses and produce plots. However, when I click on "Render" it now fails, stopping at the rows where the load.project() command is.

I do not get any detailed information for the reason, just:

processing file: qmd_test.qmd
  |.....................                               |  40% (unnamed-chunk-1)Quitting from lines 16-18 (qmd_test.qmd) 

Execution halted

You can easily re-create the error by creating a Projecttemplate project as in http://projecttemplate.net/getting_started.html and then trying to render a document in quarto loading your data through:

library('ProjectTemplate')
load.project()

I hope someone can help me.

Thank you, Francesco

PS: this is my first question on stackoverflow. I tried to include as much detail as possible on my issue and how to re-create it, but please let me know if I was unclear or you need extra information.

RStudio version 2022.12.0+353

platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
year           2021                        
month          08                          
day            10                          
version.string R version 4.1.1 (2021-08-10)
nickname       Kick Things

I tried to load different Projecttemplate projects, even the basic one that they use in the package tutorial, and everything failed, so it has nothing to do with my work project or my data.

I also tried to source an R script rather than loading the project directly in quarto, but it also fails.

2
  • Not a solution per se but just a suggestion to update your R version. And what version of ProjectTemplate are you using? Commented May 16, 2023 at 13:36
  • And - what code is in lines 16-18 (where the rendering quits)? Commented May 16, 2023 at 13:56

1 Answer 1

0

If your Quarto file is inside your reports folder (should be created by ProjectTemplate), then put this line below the YAML header (not inside a chunk):

`r knitr::opts_knit$set(root.dir='..')`

Then open a chunk and load ProjectTemplate and run load.project() like this:

```{r}
#| label: load-packages
#| include: false
library(ProjectTemplate)
load.project()

I think what the first line is doing is setting the working directory one level up, i.e. the same directory ProjectTemplate uses, but the markdown/Quarto file is using the directory where the markdown/Quarto file is. Once the directory has been set then `load.project()` works as normal.

See this answer: How to integrate R ProjectTemplate into R Markdown

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.