Hello @Philmocoucou ,
I am not sure what you mean by "I have updated the problem".
To me, it does not look at your original problem at all.
But I see now a clear error mentioned (although I don't see why the html version would render and the pdf version would fail):
Error in parse_block(g[-1], g[1], params.src, markdown_mode) :
Duplicate chunk label 'setup', which has been used for the chunk
....
This suggests to me that you maybe try to use the render function in exercise_2.Rmd . You should not do this:
use your script with the library
, setwd
and render
function and your Rmd file is a complete file with YAML, one setup chunk and other text and code chunks.
I hope this helps.
If not then answer to this post with the full script and the full Rmd file that you use, while clearly indicating what is in the script and what is in the Rmd file. The Rmd file should be enclosed with backticks: assuming you have at most 3 consecutive backticks in the Rmd file enclose it with 4 backticks.
In this way we can see the chunks and YAML. For the 'full' Rmd file you can of course leave out anything that you don't want to share, but make sure that the structure is the same.
So let us see the script, the Rmd-file and optionally output messages clearly delimited.