Is there any way to use write() and write.table() so that the output file is in a different directory than the working directory? It tried setting the path to the output file before the filename, and just get an error message.
If you're using windows, R
will know to go outside the current directory if it sees C:/
first (presumably other mounted drives too). With Macs it will go outside the current wd if it sees /
. So:
Mac OS X:
write.table(foo, file="/users/name/folder/filename.ext")
Windows
write.table(foo, file="C:/users/name/folder/filename.ext")
Always test to make sure you have the path right first!
list.files("C:/...")
list.files("/....") #Give errors if path doesn't exist as typed
So if you're in /users/parent/subdir
and you want to reference something in parent
, you must type out the full path - write.table(foo, "parent/name.ext")
will tell R to make a file: /users/parent/subdir/parent/name.ext
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With