1

这是我尝试过的代码,我尝试过的方法。基本上我只是想知道权限被拒绝的部分。

 data <- matrix(c(1,2,3,4), ncol=2)
 write.csv(data,"C:/Users/brian_000/Documents")

错误:

Error in file(file, ifelse(append, "a", "w")) : 
  cannot open the connection
 In addition: Warning message:
 In file(file, ifelse(append, "a", "w")) :
   cannot open file 'C:/Users/brian_000/Documents': Permission denied
   write.csv(data, file="C:/Users/brian_000/Documents")
  Error in file(file, ifelse(append, "a", "w")) : 
 cannot open the connection
 In addition: Warning message:
 In file(file, ifelse(append, "a", "w")) :
  cannot open file 'C:/Users/brian_000/Documents': Permission denied
4

2 回答 2

13

C:/Users/brian_000/Documents是(大概)一个目录,所以你不能像它是一个文件一样写入它。相反,写入文件,如C:/Users/brian_000/Documents/myfile.csv.

于 2013-06-13T20:44:30.123 回答
3

我在尝试执行时遇到了同样的错误:

tip_data <- read.csv('my_tipdata.csv', header = TRUE)

原因是我在 Excel 中打开了文件。一旦我关闭文件,它就会正确执行。

于 2020-05-26T20:28:54.373 回答