如何用R删除文件? [英] how to delete a file with R?
本文介绍了如何用R删除文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
自动删除R中的文件/文件夹
Possible Duplicate:
Automatically Delete Files/Folders in R
我想知道R中是否有办法检查文件是否在我的当前目录中,如果存在,则程序将其删除?
I would like to know if there is a way in R to check up if a file is in my current directory, and if it is there then the program deletes it?
我知道其他语言也可以直接访问OS功能来执行此任务,但是如果R具有这种功能,我有点怀疑.
I know that other languages have direct access to OS functions to do this task, but I am a little bit dubious if R has that capability.
推荐答案
怎么样:
#Define the file name that will be deleted
fn <- "foo.txt"
#Check its existence
if (file.exists(fn))
#Delete file if it exists
file.remove(fn)
据我所知,这是所有平台上永久的,不可恢复的(即不是移动到回收站")...
As far as I know, this is a permanent, non-recoverable (i.e. not "move to recycle bin") on all platforms ...
这篇关于如何用R删除文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文