问题
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?
回答1:
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")
回答2:
@mrub,
knit2pdf(input.Rnw, output="Custom_name.pdf")
does this works for you ?? cause if I just use
knit2pdf("222.Rnw")
it'll gives me beautiful pdf file named "222.pdf", but if I use
knit2pdf("222.Rnw",output="lalala.pdf")
it will gives a pdf file named "lalala.pdf", with no error but the content is nothing but mess.
you know why would this happen?
来源:https://stackoverflow.com/questions/21883761/how-to-knit-sweave-to-a-different-file-name