initProject {kutils} | R Documentation |
Create project directories, initialize a git repo, create README.md ChangeLog, and R template file in R directory
Description
This creates folders for the separate parts of a project. It tries to be clever about which directories are created and where they are placed. Please see details for 3 scenarios for which we have planned. If a directory already exists, it will not be damaged or re-created.
Usage
initProject(
dir = NULL,
ddir = "data",
wdir = "workingdata",
odir = "output",
tdir = "tmp",
ldir = "lit",
writedir = "writeup",
rdir = "R",
...,
gitArgs = "--shared=group"
)
Arguments
dir |
Default NULL, otherwise a legal directory name to serve as the top level directory for this project |
ddir |
Data directory, place where "read only" unadjusted data files are kept. Default is "data". If user sets it as NA or NULL, the directory will not be created. |
wdir |
Working data directory, where recorded, revised, and cleaned data files are kept. Default is "workingdata". |
odir |
Output directory. Default is "output". |
tdir |
Temporary directory, where trash files can be kept for safe keeping. Default is "tmp". |
ldir |
Literature directory, where material about the project can be stored. Default is "lit". |
writedir |
The folder where the project writeup will be stored. Default is "writeup". |
rdir |
The name to be used for the R files. Defaults to "R". |
... |
A list of other directories that the user would like to
create. For example, |
gitArgs |
This function tries to run "git init" and in our center we add "–shared=group" on a network file server. If that is undesirable in a user's context, put the argument gitArgs as "". |
Details
If the dir argument is NULL, as default, then the current working directory will be the place where new directories and the git repository will be created. Assuming the current working directory's base name is not "R", then folders named "R", "data", and so forth will be created in the current working directory.
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.
Value
Name of project top level directory. Leaves the R working directory unchanged.
Author(s)
Paul Johnson <pauljohn@ku.edu>
Examples
projdir1 <- file.path(tempdir(), "test1")
dir.create(projdir1, recursive = TRUE)
initProject(dir = projdir1)
list.files(projdir1, all.files = TRUE)
projdir2 <- file.path(tempdir(), "test2")
dir.create(projdir2, recursive = TRUE)
## demonstrate ability to create other directories
initProject(dir = projdir2, admin = "admin", clientfiles = "client")
list.files(projdir2, all.files = TRUE)
## demonstrate ability to nullify standard directories
projdir3 <- file.path(tempdir(), "test3")
dir.create(projdir3, recursive = TRUE)
initProject(projdir3, odir = NA, tdir = NA, writedir = NA)
list.files(projdir3, all.files = TRUE)
unlink(c("projdir1", "projdir2", "projdir3"), recursive = TRUE)