Reproducing analyses from a persistant project repository
Humboldt-Universität zu Berlin
Sat Aug 24, 2024
Today we will…
Germany - Frankfurt
or some other place relevant for your institution (for legal Data Protection reasons)data
scripts
or code
, or whatever you preferdata
, add the csv
file you presumably have in the same folder in your project (drag and drop, or select the big green +
)
chromy_et-al_2023_English_final.csv
scripts
folder add the scripts where we worked with the data.qmd
and .html
files aren’t viewable in-browser on the OSF)tinytex
scripts/
folderdata
folder, how you organise and name the scripts/
folder on OSF is more flexible
data
folder)Checklist: Share data and code
At this point, your OSF project should
data/
and scripts/
scripts/
will also contain the output file(s)scripts/
setwd()
?here()
package within an R project.Rproj
file at the project root directory.Rproj
file won’t mean that the person who downloads it will also have our packages
here
package, and won’t even be able to use our code to load in the dataREADME.md
will ideally have information that is useful once the project is downloaded in its entirety
here()
package to read in data)scripts/
Anonymize
, your name will be removed from the project
Anonymising your scripts (optional)
If you have a relatively large project with your name at the beginning of multiple scripts, it can be tedious to manually remove it for double-blind peer review. And you might not be sure you actually took your name out of everything!
This can be used using RStudio’s Global Find:
Cmd+Shift+F
Find:
Search in:
, choose your filepath (for me: the OSF folder only) and hit enter[Anonymized for peer review]
), and hit “Replace All”Important: this will work for HTML and R/Quarto/Rmd scripts, but not for PDFs! so you might want to re-render all PDFs. As far as I can tell you have to re-render each PDF. If you’re working in a Quarto project (and not an .Rproj
), then you can use quarto render subfoldername --to pdf
in the Terminal to re-render only the OSF PDFs. We didn’t discuss Quarto projects in this course, however.
After the manuscript is accepted, you can then reverse this step: use the Global Find to replace [Anonymized for peer review]
with your name! This is why I suggest surrounding the phrase with []
, it ensures you don’t accidentally replace the string ‘anonymized for peer review’ elsewhere in your files (e.g., maybe you wrote in some analysis plan “all scripts will be anonymized for peer review”, which would then be changed to “all scripts will be Daniela Palleschi” if I had replaced Anonymized for peer review
with my name).
Today we…
R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS Ventura 13.2.1
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
attached base packages:
[1] stats graphics grDevices datasets utils methods base
loaded via a namespace (and not attached):
[1] digest_0.6.36 fastmap_1.2.0 xfun_0.47 magrittr_2.0.3
[5] knitr_1.48 htmltools_0.5.8.1 rmarkdown_2.28 cli_3.6.3
[9] renv_1.0.7 compiler_4.4.0 rprojroot_2.0.4 here_1.0.1
[13] rstudioapi_0.16.0 tools_4.4.0 evaluate_0.24.0 Rcpp_1.0.12
[17] yaml_2.3.10 magick_2.8.3 rlang_1.1.4 jsonlite_1.8.8