Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何在运行knit和texi2pdf后移除.tex_R_Latex_Knitr - Fatal编程技术网

R 如何在运行knit和texi2pdf后移除.tex

R 如何在运行knit和texi2pdf后移除.tex,r,latex,knitr,R,Latex,Knitr,我有一个R数据帧,我使用以下代码在knitr中运行: knit('reportTemplate.Rnw', 'file.tex') # creates a .tex file from the .Rnw one texi2pdf('file.tex') # creates a .pdf file from the .tex one 在我的R脚本中,我希望以后从我的计算机文件夹中删除“file.tex”。我如何做到这一点?在.R文件中执行此操作很重要,因为

我有一个R数据帧,我使用以下代码在knitr中运行:

knit('reportTemplate.Rnw', 'file.tex')  # creates a .tex file from the .Rnw one
texi2pdf('file.tex')                    # creates a .pdf file from the .tex one

在我的R脚本中,我希望以后从我的计算机文件夹中删除“file.tex”。我如何做到这一点?在.R文件中执行此操作很重要,因为这些行实际上位于一个循环中,该循环从该模板生成1000个不同的报告。

在R中有一系列函数,允许用户与计算机的文件系统交互。运行
?files
查看可以创建、重命名和删除文件等功能


正如Josh O'Brien在对OP的评论中指出的,在这个特定的例子中,要使用的命令是
file.remove('file.tex')
file.remove('file.tex')
?@JoshO'Brien,这样做了,谢谢(这实际上有点尴尬,因为我知道
file
函数族)!您愿意将您的评论作为答案提交吗?谢谢,但是不。不过,您应该完全自由地回答问题,然后接受您的答案。或者,如果你不想这样做,你也可以删除这个问题,因为它不太可能被浏览很多次。。。干杯