简体   繁体   中英

R Write.CSV Error: Cannot Open File, Invalid Argument

This seems like a very simple question, but I can't find the answer elsewhere, so I am hoping someone here can point me in the right direction. I am writing CSVs with an R script, and have reached the following error.

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

This error is the result of the code:

x = paste(paste(ty,yr, sep=""), "logs.csv", sep="")
write.csv(logscuml, file = x, row.names = FALSE)

Where logscuml is a dataframe with 28 observations of 103 variables, ty = "Package", and yr = "2011". This particular block of code occurs within a for loop within another for loop, if that is important.

My working directory is set up correctly, and

list.files(getwd())

returns the appropriate filelist. None of the CSVs I am attempting to work with are open on my OS, so I'm not sure what the problem is. No errors are brought up when using read.csv() to open different files for reading from the same wd earlier in the R script. To make this weirder, this code seemed to work fine multiple times before. Is it because I'm writing to an onlinedrive? Can anyone help with this?

For anyone who cares about the answer, this error is the result of certain files being in "Online only" mode. A manual, non-automatic sync of the shared drive forced these problem files into being "Available offline" and eliminated the error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM