Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.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 Write.CSV错误:无法打开文件,参数无效_R_Csv - Fatal编程技术网

R Write.CSV错误:无法打开文件,参数无效

R Write.CSV错误:无法打开文件,参数无效,r,csv,R,Csv,这似乎是一个非常简单的问题,但我在别处找不到答案,所以我希望这里的人能给我指出正确的方向。我正在使用R脚本编写CSV,并出现以下错误 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 'Package2011lo

这似乎是一个非常简单的问题,但我在别处找不到答案,所以我希望这里的人能给我指出正确的方向。我正在使用R脚本编写CSV,并出现以下错误

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 'Package2011logs.csv': Invalid argument
此错误是由以下代码导致的:

x = paste(paste(ty,yr, sep=""), "logs.csv", sep="")
write.csv(logscuml, file = x, row.names = FALSE)
其中logscuml是一个数据帧,包含103个变量的28个观测值,ty=“Package”和yr=“2011”。这个特定的代码块出现在另一个for循环中的for循环中,如果这很重要的话

我的工作目录设置正确,并且

list.files(getwd())

返回相应的文件列表。我尝试使用的CSV没有一个在我的操作系统上是开放的,所以我不确定问题出在哪里。在R脚本前面使用read.csv()打开不同文件以从同一wd读取时,不会出现错误。更奇怪的是,这段代码以前似乎多次运行良好。是因为我在给一个在线驱动器写信吗?有人能帮忙吗?

对于关心答案的人来说,此错误是某些文件处于“仅联机”模式的结果。手动、非自动同步共享驱动器迫使这些问题文件“脱机可用”,并消除了错误。

什么是“联机驱动器”?你能把其他文件保存到那个目录吗?您使用的是什么操作系统?Windows 8,将文件读写到Microsoft OneDrive上的文件夹中。完全无关:
paste0(x)
paste(x,sep=”“)相同
,而且更为节省;-)尝试自行评估
文件(“Package2011logs.csv”,“w”)
;同样的错误?可能需要继续执行
close(“Package2011logs.csv”)
btw。谢谢
paste()
tip!不幸的是,通过
文件(“Package2011logs.csv”,“w”)
评估文件会产生相同的错误。