Error in output file generation

Hi all,

I am getting this error when I tried write output file using write.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 'C:/mypath/myfile.txt' : Permission denied

How to solve this ?

The most likely explanation is that this file is open in a different program (on Windows, only one program can modify a file at a time). Solution: close the other program.

If you're using the package {readr} in version 2.0, this might be the program causing the problem: when you call read_csv() or similar functions, they don't actually read the entire file, so they keep it open, meaning you can't overwrite it. This can be avoided with the option lazy = FALSE, or by installing readr 2.1 which changes the default (see here for more details).

Apart from that, it could be a direct problem of permissions: if the file is read-only, if it's in a system directory, or if it's in the Documents directory of another user, for example. You can try modifying it with the notepad to see if it's a permission problem.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.