The AEA Data Editor kicked it all off with this tweet:
“Please stop using “cd” (in Stata) or “setwd()” (in R) all over the place. Once (maybe, not really), that’s enough.”
Replies proliferated on #EconTwitter this week. In this blog post I am collecting solutions for R. These days you might share the code used to generate your results for an empirical paper. That code would ideally be easy for other people to run on their own computers. File paths are hard (as I blogged previously).
A project for a single paper might have multiple code files. The code interacts with data stored somewhere. Part of the task of the code is to point the statistical program to the data set. It is frustrating if an outsider is trying to replicate a result and must alter the code in multiple places to point to their own location of the data.
Here is a concise summary of good practice, for any code language: “cd and setwd() specify the directory. When you share code and run on a different computer, they don’t work. Therefore, good practice to only specify once, at the beginning”
Continue reading