I have this code
myvector <- c(3.45235, 1.32525, ... , 2.41351) # some numbers
write(myvector, "C:/mypath/myfile.txt") # I use "/" instead of ""
and I get 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 'C:/mypath/myfile.txt' : No such file
or directory
I read this tutorial, but I can't understant what's wrong with my code. Any idea?
edit:
As @dickoa pointed out, I need an existing path to write a file, so I tried to simplify in the following way:
file.exists("C:/")
write(myvector, "C:/myfile.txt")
Surprisingly :P the path "C:/" exists (the result is TRUE) but I get a similar 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 'C:/mypath/myfile.txt' : Permission denied
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…