How to knit/Sweave to a different file name?

倖福魔咒の 提交于 2019-12-12 13:12:58

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!