File paths in statistical software
Published:
A short thread (PSA) on a FOC (frequently occurring problem) that shouldn’t be one: file paths in statistical software.
Comment in a recent reply to one of our replication reports (note: this was not actually a problem):
“We use a HPC and a Linux environment. Therefore, the folders are separated by / and not \ . This might create problems if working with Windows.”
Actually, it does not!
Stata
Every Stata user (but in particular those on Windows) should know 👇. Rule: ALWAYS use “/
”, NEVER “\
” and you should be fine.
R
use “file.path('path','file')
” or even use packages here
or rprojroot
.
Matlab
Use “/
” and it will do the right thing.
Python
os.path.join()
is your friend
Others
And there are likely similar functions in lots of other programming languages and statistical software.
Take away
Be aware of and always use the platform independent coding of paths, either a function or using “/
”. NEVER use “\
”.