Guidance for authors wishing to create data and code supplements, and for replicators.
basepath <- file.path(“My Documents”,”Paper 15”)
basepath = rprojroot::find_root(rprojroot::is_git_root)
includes <- file.path(basepath,”includes”) inputdata <- file.path(basepath,”inputdata”) tables <- file.path(basepath,”text/tables”) matsize <- 11000
### Use of relative paths in main program for inclusions
Discouraged:
source(“C:\My Documents\yesterdays programs\submodule.do”)
- Encouraged:
source(file.path(includes,”submodule.R”))
or
source(file.path(“includes”,”submodule.R”)
### Installing packages in a project-specific directory
- using the `packrat` package
- using `containerit` package
- manually resetting the R library locations in the config file, then installing packages
.libPaths( c( includes , .libPaths() ) )
You can then create a single dependency file that is run before all others:
00_install.R:
include “config.R” install.packages(‘rddensity’, lib=libpath, destdir=libpath) install.packages(‘rdrobust’, lib=libpath, destdir=libpath) install.packages(‘gridExtra’, lib=libpath, destdir=libpath) install.packages(‘ggplot2’, lib=libpath, destdir=libpath)
and in your main program
basepath = rprojroot::find_root(rprojroot::is_git_root) source(file.path(basepath,”config.R”)) library(rdrobust) library(rddensity) library(gridExtra) library(ggplot2) ``` will always work, because it no longer requires download, and fixes the version of the packages used.