Thank you for your comment @andresrcs.
I am really interested in finding a solution to the problem so I have been doing a little more troubleshooting. For some reason it seems that R is simply unable (not allowed) to write to the majority of my directories (except for a scant few where it is set to execute).
I simply started setting my working directory to various spots and then tried to write a little CSV.
This works as expected:
dummy <- "test"
setwd("C:/Users/mario/OneDrive - Ribon Therapeutics/R projects")
head(dir())
#> [1] "__install files" "_books and manuals" "_cheat sheets"
#> [4] "_scratch" "_themes" "20200507_EB_NAFLD-NASH"
write.csv(dummy, "___test.csv")
head(dir())
#> [1] "___test.csv" "__install files" "_books and manuals"
#> [4] "_cheat sheets" "_scratch" "_themes"
As does this:
dummy <- "test"
setwd("C:/Users/mario")
head(dir())
#> [1] "3D Objects" "AppData" "Application Data" "Contacts"
#> [5] "Cookies" "Desktop"
write.csv(dummy, "___test.csv")
head(dir())
#> [1] "___test.csv" "3D Objects" "AppData" "Application Data"
#> [5] "Contacts" "Cookies"
But this fails:
dummy <- "test"
setwd("C:/Users/mario/Documents")
head(dir())
#> [1] "___Zwift Backup" "Aquarium" "auctions" "Audiobooks"
#> [5] "Bert Gift" "Blog"
write.csv(dummy, "___test.csv")
#> Warning in file(file, ifelse(append, "a", "w")): cannot open file '___test.csv':
#> No such file or directory
#> Error in file(file, ifelse(append, "a", "w")): cannot open the connection
head(dir())
#> [1] "___Zwift Backup" "Aquarium" "auctions" "Audiobooks"
#> [5] "Bert Gift" "Blog"
As does this:
dummy <- "test"
setwd("C:/Users/mario/Documents/R/win-library/4.0")
head(dir())
#> [1] "abind" "afex" "askpass" "assertthat" "backports"
#> [6] "base64enc"
write.csv(dummy, "___test.csv")
#> Warning in file(file, ifelse(append, "a", "w")): cannot open file '___test.csv':
#> No such file or directory
#> Error in file(file, ifelse(append, "a", "w")): cannot open the connection
head(dir())
#> [1] "abind" "afex" "askpass" "assertthat" "backports"
#> [6] "base64enc"
So this suggests to me it has something to do with the oddity that is the documents folder in Windows. The bizarre thing is that this is where the R libraries have always been and I have not implemented any changes! Bizzarre.
Created on 2021-02-10 by the reprex package (v0.3.0)