File: initProject.Rd

package info (click to toggle)
r-cran-kutils 1.73%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,648 kB
  • sloc: sh: 13; makefile: 2
file content (114 lines) | stat: -rw-r--r-- 4,326 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/project.R
\name{initProject}
\alias{initProject}
\title{Create project directories, initialize a git repo, create README.md
ChangeLog, and R template file in R directory}
\usage{
initProject(
  dir = NULL,
  ddir = "data",
  wdir = "workingdata",
  odir = "output",
  tdir = "tmp",
  ldir = "lit",
  writedir = "writeup",
  rdir = "R",
  ...,
  gitArgs = "--shared=group"
)
}
\arguments{
\item{dir}{Default NULL, otherwise a legal directory name to serve
as the top level directory for this project}

\item{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.}

\item{wdir}{Working data directory, where recorded, revised, and
cleaned data files are kept. Default is "workingdata".}

\item{odir}{Output directory. Default is "output".}

\item{tdir}{Temporary directory, where trash files can be kept for
safe keeping. Default is "tmp".}

\item{ldir}{Literature directory, where material about the project
can be stored. Default is "lit".}

\item{writedir}{The folder where the project writeup will be
stored. Default is "writeup".}

\item{rdir}{The name to be used for the R files. Defaults to "R".}

\item{...}{A list of other directories that the user would like to
create. For example, \code{adir = "admin"}, \code{cdir =
"client_provided"}, \code{bdir = "codebooks"}, \code{sdir =
"Stata"}, \code{mdir = "Mplus"}. These may be grouped in a
named vector or list, if user convenience dictates.}

\item{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 "".}
}
\value{
Name of project top level directory. Leaves the R
    working directory unchanged.
}
\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.
}
\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 \code{"/tmp/whatever/R"}), and the user runs
\code{initProject()}, something different happens. The function
assumes we don't want to create subdirectories inside R. We don't
want to end up with \code{"/tmp/whatever/R/R"}. We don't
want \code{"/tmp/whatever/R/data"} either.  Instead, it assumes we
want the new directories created on same level as R, so it creates
\code{"/tmp/whatever/data"}, \code{"/tmp/whatever/workingdata"},
and so forth.  From within the R directory, these new directories
are seen as \code{"../data"}, \code{"../workingdata"}, and so
forth. That is, we should end up with directories and a git repo
in \code{"/tmp/whatever"}.

If the \code{dir} argument is provided by the user, then that is
used as the folder in which directories \code{"R"}, \code{"data"},
\code{"workingdate"}, and so forth are created.  All materials are
created in \code{dir}, no matter what the current working
directory is named (even if it is \code{"R"}).

The examples demonstrate all three of these scenarios.
}
\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)
}
\author{
Paul Johnson <pauljohn@ku.edu>
}