0

I am interested in rendering multiple outputs using the knit button.

I have found this answer but I do not understand how to edit the knit: call to do just that.

Thank you for any pointer,
Ivan

  • If you don't understand an answer, post a comment asking for clarification, don't ask a duplicate question. – user2554330 Apr 08 '20 at 09:57
  • 1
    Since I'm a new user I am not allowed to comment. And I tried "adding another answer", but my post was just deleted. –  Apr 08 '20 at 10:19
  • sorry about that. Sounds like SO has some bad rules. – user2554330 Apr 08 '20 at 11:55
  • You probably could describe the code you have as well as the desired result and your result (e.g. potential error codes etc) – Oka Apr 08 '20 at 12:06

2 Answers2

2

OK, I got it, this is what I need:

knit: (function(inputFile, encoding) {
  rmarkdown::render(inputFile, 
                    encoding = encoding, 
                    output_format = "all", 
                    knit_root_dir = rprojroot::find_rstudio_root_file()) 
  })

There might be a better way to find the project directory though, but I couldn't find anything.

0

Just use the answer from this answer as YAML header

---
title: "multiple outputs"
output:
  word_document: default
  html_document: default
knit: (function(inputFile, encoding) {
  rmarkdown::render(inputFile, encoding = encoding,
  output_format = "all") })
---

TEST

J_F
  • 9,956
  • 2
  • 31
  • 55
  • OK, so the problem is somewhere else, and probably with the working directory during the rendering. Apparently, when I use this command, the file is not knitted anymore in the project directory. And since I access files in different folders relative to the project directory, this is needed. What can I do then? –  Apr 08 '20 at 10:08
  • I edited my answer and removed the output folder from the command. – J_F Apr 08 '20 at 10:15
  • I could use the here() package, but it would be nice to still be able to knit in the project directory with this command. –  Apr 08 '20 at 10:15