how to remove the file when “permisson denied” in R?

My system is "win7", and I want to delete the file "workspace".

file.remove("c:\\workspace")
# [1] FALSE
# Warning message:
# In file.remove("c:\\workspace") :
# cannot remove file 'c:\workspace', reason 'Permission denied'

How can I give the R the power to delete it?

file.info("c:\\workspace")
#               size isdir mode               mtime               ctime
# c:\\workspace    0  TRUE  777 2014-01-01 14:42:51 2014-01-01 14:33:27
#                             atime exe
# c:\\workspace 2014-02-25 09:39:08  no

Answers


@TypeIA answered it in a comment, but I'll formalize it here: help(unlink).

file.create('somefile')
# [1] TRUE
file.remove('somefile')
# [1] TRUE

dir.create('somedir')
file.remove('somedir')
# [1] FALSE
# Warning message:
# In file.remove("somedir") :
#   cannot remove file 'somedir', reason 'Permission denied'
unlink('somedir', recursive=TRUE)

(The directory is gone.)


Need Your Help

Split transformation steps based on Parameter in Pentaho Data Integration

pentaho etl data-integration

I have a transformation with a boolean parameter. If the parameter is 1, I want the data to flow through one transformation path. But if the parameter is 0, I want it to flow through a different

Why throwing exception in constructor results in a null reference?

c# exception object constructor null

Why throwing exception in constructor results in a null reference?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.