gpt4 book ai didi

r - R中的 "permisson denied"如何删除文件?

转载 作者:行者123 更新时间:2023-12-04 07:02:11 24 4
gpt4 key购买 nike

我的系统是“win7”,我想删除文件“workspace”。

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

如何赋予R删除权限?
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

最佳答案

@TypeIA在评论中回答了它,但是我将在这里将其形式化: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)

(目录已消失。)

关于r - R中的 "permisson denied"如何删除文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22122968/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com