I have this code
myvector <- c(3.45235, 1.32525, ... , 2.41351) # some numbers
write(myvector, \"C:/mypath/myfile.txt\") # I use \"/\" instea
I just shared this answer with a bit of a better explanation here, but the gist of it is:
Try opening the file in Excel to see if it's locked by another user. I was receiving the same error messages and was able to figure out that a colleague had the file open on their computer which had locked me out of the ability to edit it.