
Last chance! 50% off unlimited learning
Sale ends in
initProject(dir = NULL, ddir = "data", wdir = "workingdata",
odir = "output", tdir = "tmp", ldir = "lit", writedir = "writeup",
rdir = "R", ..., gitArgs = "--shared=group")
adir = "admin"
, cdir =
"client_provided"
, bdir = "codebooks"
, sdir =
"Stata"
, mdir = "Mplus"
. These may be grouped in a
named vector or list, if user convenience dictates.If one has a current R working directory with a basename "R"
(suppose it is "/tmp/whatever/R"
), and the user runs
initProject()
, something different happens. The function
assumes we don't want to create subdirectories inside R. We don't
want to end up with "/tmp/whatever/R/R"
. We don't
want "/tmp/whatever/R/data"
either. Instead, it assumes we
want the new directories created on same level as R, so it creates
"/tmp/whatever/data"
, "/tmp/whatever/workingdata"
,
and so forth. From within the R directory, these new directories
are seen as "../data"
, "../workingdata"
, and so
forth. That is, we should end up with directories and a git repo
in "/tmp/whatever"
.
If the dir
argument is provided by the user, then that is
used as the folder in which directories "R"
, "data"
,
"workingdate"
, and so forth are created. All materials are
created in dir
, no matter what the current working
directory is named (even if it is "R"
).
The examples demonstrate all three of these scenarios.
tempdir <- tempdir()
setwd(tempdir)
dir.create("test0")
setwd("test0")
initProject()
list.files(all.files = TRUE)
setwd(tempdir)
dir.create("test1")
setwd("test1")
## demonstrate ability to create other directories
initProject(admin = "admin", clientfiles = "client")
list.files(all.files = TRUE)
setwd(tempdir)
dir.create("test2/R", recursive = TRUE)
setwd("test2/R")
initProject(adir = "accounting")
list.files(all.files = TRUE)
list.files("../", all.files = TRUE)
setwd(tempdir)
initProject("test3")
list.files("test3", all.files = TRUE)
setwd(tempdir)
## demonstrate ability to create other directories
initProject(file.path(tempdir, "test4"),
list(mdir = "Mplus", sasdir = "SAS"))
list.files(file.path(tempdir, "test4"), all.files = TRUE)
setwd(tempdir)
## demonstrate ability to nullify standard directories
initProject("test5", odir = NA, tdir = NA, writedir = NA)
list.files("test5", all.files = TRUE)
unlink(c("test1", "test2", "test3", "test4", "test5"), recursive = TRUE)
Run the code above in your browser using DataLab