Get access to all lessons in this course.
- Welcome to Reproducibility for the Rest of Us
- Reproducibility for the Rest of Us Course Logistics
- Using Space Wisely
- Naming All the Things
- Using Function Arguments
- Prologs & Annotation
- Using Seed Values
- Writing Functions for Repeated Tasks
- Literate Programming with Quarto
- Embedding Files to Improve Reproducibility
- Managing Project Files for Reproducibility
Reproducibility for the Rest of Us
Managing Project Files for Reproducibility
This lesson is locked
This lesson is called Managing Project Files for Reproducibility, part of the Reproducibility for the Rest of Us course. This lesson is called Managing Project Files for Reproducibility, part of the Reproducibility for the Rest of Us course.
Transcript
Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.
You need to be signed-in to comment on this post. Login.
Emma Spielfogel
October 19, 2023
What is the advantage of using "here" instead of just typing the subfolder name in the path? Isn't it hard-coded either way so it would be the same amount of work to update if the files got moved around or folders got renamed?
As in, why in this example is it preferable to put: globalData2019 <- read_spss(here("globaldata","Pew Research Center Global Attitudes Spring 2019 Dataset WEB.sav"))
instead of: globalData2019 <- read_spss("globaldata/Pew Research Center Global Attitudes Spring 2019 Dataset WEB.sav")
?
David Keyes
October 20, 2023
Please see Jenine's answer below. In addition, this article by Malcolm Barrett gives some idea about why you might want to use here even when working in an RStudio project.
I will also say that I tend to use it when working in projects with both Quarto/RMarkdown documents and R script files. That's because the working directory of Quarto/RMarkdown documents is wherever they are located while for R script files it is the root of the project. The
here
package can help ensure that code works identically in either type of file.Jenine Harris
October 20, 2023
The here package helps to avoid problems with working directories when collaborating. If your collaborator has the working directory manually set (or defaulted) to somewhere other than the top folder of the project, the second version you posted would not work for them. In many cases, the second will work just fine and is less typing, for sure, but then you'll get one collaborator with a stubborn installation or a habit of using setwd() at the start of their workflow and there will be trouble. Using R Project files also helps to avoid problems with working directories. Here is a nice description of this issue: https://www.tidyverse.org/blog/2017/12/workflow-vs-script/
At the very least, you'll avoid Jenny Bryan setting your computer on fire.
Thanks for the great question!