New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Output Format-specific output_file
#277
Comments
|
Another possibility for you is to keep your previous workflow and just define a custom knit function inside your document. If you add a metadata field named "knit" with the name of an R function that will be called rather than render. The hookup to the RStudio previewer is a bit delicate but possible: so long as the the string "Output created: " exists in the console output from your custom knit that file will then be shown in the appropriate previewer. |
|
That sounds pretty slick. Would this be a replacement for Would this "knit" field be defined as a knitr hook or option? Could this be specified in the knitr options to |
|
The function called from the "knit" entry needs to produce everything The "knit" field would be included directly in the document YAML metadata. On Tue, Oct 14, 2014 at 10:20 AM, Jamie F Olson notifications@github.com
|
|
Are these YAML "hooks" documented anywhere? Would it be possible to hook into the "Knit HTML" and "Knit PDF" buttons, too? |
|
No, they aren't documented (yet). If you have this hook enabled then the On Tue, Oct 14, 2014 at 11:06 AM, Jamie F Olson notifications@github.com
|
|
Are there any arguments passed to the "knit" function? |
|
Yes (see the example I linked to previously). On Wed, Oct 15, 2014 at 2:00 PM, Jamie F Olson notifications@github.com
|
|
So the only arguments specified for the "knit" function are the filename and the encoding, both passed as unnamed arguments? |
|
Yes that's exactly right. On Wed, Oct 15, 2014 at 2:10 PM, Jamie F Olson notifications@github.com
|
|
Thanks! |
|
For anyone else who came across this searching, the hook function can be anonymous, but has to be a one-liner, e.g. a knit function to set the output filename to "README.md": knit: (function(inputFile, encoding) { rmarkdown::render(inputFile, encoding = encoding, output_file = paste0(dirname(inputFile),'/README.md')) })Metadata is still used to set the contents of the file as expected. See also this related StackOverflow Q&A |
|
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
I am currently using various knitr options with pandoc to render multiple distinct versions of an output file to different locations.
To clarify, I have a top-level directory structure like:
srcbuilddataI currently place all knitr cache, knitr figures, build markdown and pdf/html output in the
builddirectory. This makes it easier to identify generated artifacts from the source files, as well as keep multiple output (from multiple knit/pandoc calls) files separate.It would be great if I could transition this process over to
renderusing differentoutput_formats and use the Rstudio UI. However, it seems that both the intermediate and output files are defined insiderenderbased on the filename when nooutput_fileargument is defined (as happens from the rstudio UI). This means that I'd need to use a post-processor to move the initial output file to my target location, populating my source directory with ambiguous output.Maybe
output_formatcould return a filename to render so thatoutput_formats could choose theiroutput_files?The text was updated successfully, but these errors were encountered: