Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to knit/Sweave to a different file name?

Tags:

r

knitr

sweave

By default, the knit/Sweave command will generate a tex file with the same name as the .Rnw file. I want to give it and the subsequent pdf file a different name is it possible?

like image 574
Avinash Avatar asked Oct 21 '22 14:10

Avinash


1 Answers

In the header of an .Rmd file, you can specify a file name:

---
title: "My title"
output:
  pdf_document:
    pandoc_args: [ 
      "--output=Custom_name.pdf" 
    ]
---

For .Rnw files you can directly call the function knitr::knit2pdf:

knit2pdf(input.Rnw, output="Custom_name.pdf") 
like image 70
mrub Avatar answered Nov 01 '22 11:11

mrub