Why I get this error writing data to a file

I know @dickoa answered the question in the comments, but in order to provide at least one answer here, I wanted to go through a few simple gotchas with R on Windows.

  1. When you are using Windows, you still have to use forward slashes for paths. In R, backslashes are reserved for escaping values. So a path in R looks like: C:/path/to/my/directory
  2. In newer variants of Windows, the C:\ is protected from writes by user accounts. If you want to write to the C:\, you must be an administrator. You can accomplish this by right-clicking on the R icon in Windows and choosing “Run as an administrator.” This should also be done when you’re installing packages. You may not have rights to install packages on certain Windows versions if you don’t run it as an administrator.
  3. If you don’t want to run R as an administrator, and you want to write to files, you will by default have rights to the C:/Users/username/ directory.

All credit to @dickoa again for his answer in first.

Best of luck!

Leave a Comment

error code: 523