Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7ca15dd
Showing
32 changed files
with
1,529 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Package: prodigenr | ||
Title: Research Project Directory Generator | ||
Version: 0.2.6 | ||
Authors@R: person("Luke", "Johnston", , "lwjohnst@gmail.com", c("aut", "cre")) | ||
Description: Create a project directory structure, along with typical files | ||
for that project. This allows projects to be quickly and easily created, | ||
as well as for them to be standardized. Designed specifically with scientists | ||
in mind (mainly bio-medical researchers, but likely applies to other fields). | ||
Depends: R (>= 3.1.2) | ||
License: MIT + file LICENSE | ||
LazyData: true | ||
Suggests: rmarkdown, git2r, packrat, knitr, testthat | ||
RoxygenNote: 5.0.1 | ||
VignetteBuilder: knitr | ||
URL: https://github.com/lwjohnst86/prodigenr | ||
BugReports: https://github.com/lwjohnst86/prodigenr/issues | ||
NeedsCompilation: no | ||
Packaged: 2016-04-29 17:00:58 UTC; luke | ||
Author: Luke Johnston [aut, cre] | ||
Maintainer: Luke Johnston <lwjohnst@gmail.com> | ||
Repository: CRAN | ||
Date/Publication: 2016-04-30 00:16:00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
YEAR: 2015-2016 | ||
COPYRIGHT HOLDER: Luke W. Johnston |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
90c17f84d693b77792afa99e9aa4b23a *DESCRIPTION | ||
ddb53d8ec14a4592849266ac05157e5e *LICENSE | ||
8faea9a4680950417c132141bfee75bc *NAMESPACE | ||
ce221787641d1ed5844f28754184f4dc *R/list_templates.R | ||
0477f91b27e684ae413c53482f41c3f1 *R/prodigen.R | ||
f49e52a95dbc55b7b1c0856c3755e30f *README.md | ||
9074b79483d35651b2642f68e2c28f15 *build/vignette.rds | ||
3ff2055d4844bd21aab5b429efc415e1 *inst/doc/introduction.R | ||
f9128e5f5764852cf28d0fbf10948eb7 *inst/doc/introduction.Rmd | ||
06e247865cb9d673cba31dc6a11518f1 *inst/doc/introduction.html | ||
bb92aaaf3f0bbb1be7ce62e99da5a5ad *inst/templates/files/R/fetch_data.R | ||
b83f6ec5d25726cd87ef3189fdbed33b *inst/templates/files/R/functions.R | ||
d79fa66d7f1a85d11fbb18095bc48331 *inst/templates/files/R/load_data.R | ||
092ab4df59fd1ea8f984a4d58b59b834 *inst/templates/files/R/setup.R | ||
0f57d75254a0e7625d240f7443c9bd86 *inst/templates/files/README.md | ||
fee8a18773f6a58061cf7aef69a6c9b6 *inst/templates/projects/abstract/README-append.md | ||
f3566f0b5172098d11d1f60ab7391f87 *inst/templates/projects/abstract/abstract.Rmd | ||
ac754814e641869e0d2ce4b76ac9402a *inst/templates/projects/manuscript/README-append.md | ||
55658a0e8e31ba29da81389cc53c054c *inst/templates/projects/manuscript/doc/manuscript.Rmd | ||
4c7635a8de8b8c4d9f57f48f7a70cb1b *inst/templates/projects/poster/README-append.md | ||
0902a70397f07d23b8aee6a14df41bf3 *inst/templates/projects/poster/beamerthemeCustomPoster.sty | ||
d40ce241c60b815789f69333621a8f1e *inst/templates/projects/poster/poster.Rmd | ||
fc71f152dec9d2fbcc04a17212e68428 *inst/templates/projects/poster/template.tex | ||
18a13da95db5d5dcfcf21647630dddf4 *inst/templates/projects/slides/README-append.md | ||
66ef33c363ef0e9d8e8fedf0353aeb77 *inst/templates/projects/slides/slides.Rmd | ||
b08302683d33c2deb73b2fbd566a5e09 *inst/templates/projects/slides/template.tex | ||
689560a39942f835159b1c9af082af6b *man/list_templates.Rd | ||
c0ef83876a625c902c099a9e5dac2240 *man/prodigen.Rd | ||
2ffba69e65ca57623c926451edbcc829 *tests/testthat.R | ||
deb68e1c9003a63d9bca0820f422d5d9 *tests/testthat/test-projects.R | ||
f9128e5f5764852cf28d0fbf10948eb7 *vignettes/introduction.Rmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
export(list_templates) | ||
export(prodigen) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#' List project templates within \pkg{prodigenr}. | ||
#' | ||
#' Get a list of available templates in a package. | ||
#' | ||
#' @param type Type of template (file or directory, aka project) | ||
#' @param package Name of package | ||
#' @return Vector of templates available | ||
#' @export | ||
#' @examples | ||
#' | ||
#' list_templates('projects') | ||
#' list_templates() | ||
#' | ||
list_templates <- function(type = 'projects', package = 'prodigenr') { | ||
temp.type <- match.arg(type) | ||
if (temp.type == 'projects') { | ||
list.dirs(system.file('templates', temp.type, package = package), | ||
full.names = FALSE, recursive = FALSE) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
##' Create a project directory and associated files. | ||
##' | ||
##' The main workhorse of the \pkg{prodigenr} package. Creates a | ||
##' project directory layout, with template files and helper scripts. | ||
##' @title Create a project directory based on a template | ||
##' | ||
##' @param proj.type type of project to create, based on the templates found in | ||
##' \code{\link[prodigenr]{list_templates}} function | ||
##' @param proj.name name of the new project directory | ||
##' @param proj.path location of where the new project will be created | ||
##' @param git.init Logical, whether to initialize the new project with git | ||
##' @param packrat.init Logical, whether to track the R package usage with | ||
##' packrat. | ||
##' @return Creates a project directory with files and subdirectories | ||
##' @export | ||
##' @author Luke W. Johnston | ||
##' @examples | ||
##' | ||
##' \dontrun{ | ||
##' ## Get a list of possible project templates | ||
##' list_templates('projects') | ||
##' # Create a project. Best done in a fresh R console. | ||
##' prodigen('poster', 'poster', 'dev/', TRUE, FALSE) | ||
##' prodigen('poster', 'poster', 'path/to/dir/', FALSE) | ||
##' prodigen('poster', 'posterName', git.init = FALSE) | ||
##' prodigen('slides', 'conference-presentation', packrat.init = FALSE) | ||
##' prodigen('abstract', 'name', './', FALSE) | ||
##' prodigen('manuscript', proj.path = './', git.init = TRUE) | ||
##' } | ||
prodigen <- function(proj.type, proj.name = NULL, proj.path = getwd(), | ||
git.init = FALSE, packrat.init = FALSE) { | ||
|
||
proj.type <- match.arg(proj.type, list_templates()) | ||
if (is.null(proj.name)) { | ||
proj.name <- proj.type | ||
} else if (!is.character(proj.name)) { | ||
stop('Please use a character string (ie. in quotes) for the project name.') | ||
} | ||
|
||
if (!dir.exists(proj.path)) | ||
stop('Please use a proj.path that currently exists on your computer.') | ||
|
||
proj_old <- file.path(proj.path, proj.type) | ||
proj_new <- file.path(proj.path, proj.name) | ||
|
||
if (file.exists(proj_new)) | ||
stop('Project already exists, please use a different proj.name.') | ||
|
||
proj.files <- system.file('templates', 'projects', proj.type, package = 'prodigenr') | ||
file.copy(proj.files, | ||
proj.path, recursive = TRUE) | ||
file.rename(proj_old, proj_new) | ||
|
||
# Copy over the RStudio, Rprofile, and R/ files | ||
template.files <- system.file('templates', 'files', | ||
package = 'prodigenr') | ||
template.files <- list.files(template.files, all.files = TRUE, | ||
full.names = TRUE, | ||
include.dirs = FALSE)[-1:-2] | ||
file.copy(template.files, | ||
file.path(proj_new), recursive = TRUE) | ||
|
||
file.rename(file.path(proj_new, 'rstudio.Rproj'), | ||
file.path(proj_new, paste0(proj.name, '.Rproj'))) | ||
|
||
file.append(file.path(proj_new, 'README.md'), | ||
file.path(proj_new, 'README-append.md')) | ||
file.remove(file.path(proj_new, 'README-append.md')) | ||
|
||
if (git.init & requireNamespace('git2r', quietly = TRUE)) { | ||
repo <- git2r::init(proj_new) | ||
gitignore.file <- file.path(proj_new, '.gitignore') | ||
if (!file.exists(gitignore.file)) | ||
file.create(gitignore.file, showWarnings = FALSE) | ||
write('.RData\n.Rout\ndata/\n.Rhistory\n.Rproj.user', | ||
file = gitignore.file, append = TRUE) | ||
} | ||
|
||
if (packrat.init & requireNamespace('packrat', quietly = TRUE)) { | ||
packrat::init( | ||
proj_new, enter = FALSE, | ||
options = list( | ||
vcs.ignore.lib = TRUE, | ||
vcs.ignore.src = TRUE | ||
) | ||
) | ||
} | ||
|
||
if (git.init & requireNamespace('git2r', quietly = TRUE)) { | ||
git2r::add(repo, unlist(git2r::status(repo, verbose = FALSE))) | ||
git2r::commit(repo, 'Initial commit') | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# prodigenr | ||
|
||
[![Build Status](https://travis-ci.org/lwjohnst86/prodigenr.svg?branch=master)](https://travis-ci.org/lwjohnst86/prodigenr) | ||
|
||
This is a *pro*ject *di*rectory *gen*erato*r* (`prodigenr`) that will | ||
create a project directory structure with template files necessary for | ||
managing and analyzing data for a variety of projects. This allows | ||
for a standardized approach to having a modular research project. | ||
This package can be found at | ||
[on the GitHub `prodigenr` repo](https://github.com/lwjohnst86/prodigenr). Note, | ||
this is still in development. | ||
|
||
# How to install | ||
|
||
Install by forking or cloning this repo, or by using the R command: | ||
|
||
devtools::install_github('lwjohnst86/prodigenr') | ||
|
||
# Usage | ||
|
||
The main function is the `prodigen` command. So, for instance, if you | ||
want a manuscript project, type out: | ||
|
||
library(prodigenr) | ||
prodigen(proj.name = 'cancerAndToxins', | ||
proj.type = 'manuscript', proj.path = '/path/to/new/project') | ||
|
||
This then creates a directory tree, with template files for starting | ||
your analysis! The main secondary function is the `list_templates` | ||
command, which lists the available template projects and files (submit | ||
a PR if you want another template included!): | ||
|
||
list_templates('projects') ## Shows project templates | ||
|
||
For a more detailed tutorial, see the vignette (still in development): | ||
|
||
vignette('introduction', 'prodigenr') | ||
|
||
# Related packages or projects | ||
|
||
There are several ways of creating projects, each of which has it's pros and cons. | ||
|
||
- [`ProjectTemplate`](http://projecttemplate.net/) | ||
- [`makeProject`](https://cran.r-project.org/package=makeProject) | ||
- R package structure via | ||
[`devtools`](https://cran.r-project.org/package=devtools), argued for in this | ||
[blog](https://rmflight.github.io/posts/2014/07/vignetteAnalysis.html) | ||
|
||
`prodigenr` tries to use ideas from R packages/`devtools` while still being as simple | ||
as possible and be more specific to academic researchers primarily in | ||
biomedical/non-computer science fields. However, it can always improve! I | ||
welcome any suggestions, just submit a | ||
[GitHub issue](https://github.com/lwjohnst86/prodigenr/issues)! |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
## ----templates, collapse=TRUE-------------------------------------------- | ||
library(prodigenr) | ||
list_templates() | ||
|
||
## ---- eval=FALSE--------------------------------------------------------- | ||
# prodigen('manuscript', 'ManuscriptName', '~/path/to/new/project') | ||
|
||
## ---- eval=FALSE--------------------------------------------------------- | ||
# prodigen('manuscript', 'ManuscriptName', '~/path/to/new/project', git.init = TRUE) | ||
|
||
## ---- eval=FALSE--------------------------------------------------------- | ||
# prodigen('manuscript', 'ManuscriptName', '~/path/to/new/project', packrat.init = TRUE) | ||
|
||
## ---- eval=FALSE--------------------------------------------------------- | ||
# prodigen('slides', 'PresentationName', '~/path') | ||
# prodigen('abstract', 'Name', '.') # Current directory | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
title: "Introduction to prodigenr" | ||
author: "Luke W. Johnston" | ||
date: "`r Sys.Date()`" | ||
output: rmarkdown::html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{Introduction to prodigenr} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteEncoding{UTF-8} | ||
--- | ||
|
||
Are you an academic researcher who often writes up abstracts for conferences or | ||
submits manuscripts to journals? Do you often have to make slides or posters for | ||
presentations? Is your usual workflow to copy a previous project and start | ||
replacing the old text for the new text? This R package was designed with you in | ||
mind! | ||
|
||
`prodigenr`, or *pro*ject *di*rectory *gen*erator, simplifies the process of | ||
creating these new projects and can help make your workflow more reproducible. | ||
Standard files and folders are created for specific projects (e.g. abstracts or | ||
manuscripts), along with a workflow that tries to be simple and easy to use. | ||
|
||
Because researchers often write or create many papers, slides, posters, and | ||
abstracts, it can quickly become tedious and messy to always make a new | ||
directory with all the necessary files and organization. | ||
|
||
## The main command: `prodigen` | ||
|
||
To use `prodigenr`, you simply need to use the `prodigen` command. At present, | ||
there are only four template projects that you can view using: | ||
|
||
```{r templates, collapse=TRUE} | ||
library(prodigenr) | ||
list_templates() | ||
``` | ||
|
||
These templates are projects that an academic researcher typically encounters. | ||
However, if you have a suggestion or want to add a template, please create a | ||
[Github issue](https://github.com/lwjohnst86/prodigenr/issues) or submit a [Pull Request](https://github.com/lwjohnst86/prodigenr/pulls)! | ||
|
||
Starting a manuscript? Create a project directory like so: | ||
|
||
```{r, eval=FALSE} | ||
prodigen('manuscript', 'ManuscriptName', '~/path/to/new/project') | ||
``` | ||
|
||
Do you use [Git](https://git-scm.com/)? You can start a git repository in the new project simply through the `git.init` argument: | ||
|
||
```{r, eval=FALSE} | ||
prodigen('manuscript', 'ManuscriptName', '~/path/to/new/project', git.init = TRUE) | ||
``` | ||
|
||
Or if you need to use [Packrat](https://rstudio.github.io/packrat/), start it with `packrat.init`: | ||
|
||
```{r, eval=FALSE} | ||
prodigen('manuscript', 'ManuscriptName', '~/path/to/new/project', packrat.init = TRUE) | ||
``` | ||
|
||
The same procedure is used for making the other project templates. | ||
|
||
```{r, eval=FALSE} | ||
prodigen('slides', 'PresentationName', '~/path') | ||
prodigen('abstract', 'Name', '.') # Current directory | ||
``` | ||
|
||
A `README.md` file is contained within each project that explains more about | ||
what each folder does and what some of the files do that were created. | ||
|
||
The end goal of each project is to be as self contained as possible. So that if | ||
you ever need to go back to the analysis, it is easy to re-run the code and get | ||
the results that you say you got. This is especially useful if others such as | ||
reviewers ask for something or want to confirm your results. For more | ||
information on good practices to use in making an analysis project, see | ||
[here](http://stats.stackexchange.com/questions/2910/how-to-efficiently-manage-a-statistical-analysis-project) | ||
or | ||
[here](http://www.r-bloggers.com/managing-a-statistical-analysis-project-%E2%80%93-guidelines-and-best-practices/)) | ||
|
||
## Workflow when using projects created from `prodigenr` | ||
|
||
A typical workflow would be to: | ||
|
||
1. Write up your analysis and associated written explanations of the results, as | ||
you would for any research project, in the abstract, poster, slides, or | ||
manuscript `.Rmd` ([R Markdown](http://rmarkdown.rstudio.com/)) file. | ||
2. Any piece of code you use more than once or is fairly complex, convert it | ||
into a function. Put this new function into the `R/functions.R` file. | ||
3. Fetch and wrangle your data in the `R/fetch_data.R` and to use the data, load | ||
it using `load_data()`. | ||
4. Knit the `.Rmd` file. You now have your final abstract, poster, slides, or | ||
manuscript to use for your research. | ||
|
||
## Related packages or projects | ||
|
||
There are several ways of handling a project. There is at least two packages | ||
that have similar goals as `prodigenr` as well as through the use of the R | ||
package structure: | ||
|
||
- [`ProjectTemplate`](http://projecttemplate.net/) is well documented and still | ||
actively developed. Only downside is that it is fairly complicated to use and | ||
complex in the project workflow it creates. | ||
- [`makeProject`](https://cran.r-project.org/package=makeProject) | ||
is very simple and stripped down in what it creates and in it's use. Downside is | ||
that it wasn't updated since 2012. | ||
- Use of the R package structure via | ||
[`devtools`](https://cran.r-project.org/package=devtools), | ||
which is argued for in this | ||
[blog](https://rmflight.github.io/posts/2014/07/vignetteAnalysis.html) and | ||
compared to `ProjectTemplate` in this | ||
[blog](https://rmflight.github.io/posts/2014/07/zpackages_vs_projectTemplate.html)). | ||
|
||
It's up to you to decide which style to use. The goal behind creating | ||
`prodigenr` was to incorporate the ideas behind R packages and mesh well with | ||
RStudio, while also trying to be as simple as possible so it is in some ways a | ||
hybrid between `ProjectTemplate` and `makeProject`. It can always be improved, | ||
so if you have suggestions just submit a | ||
[GitHub issue](https://github.com/lwjohnst86/prodigenr/issues)! |
Oops, something went wrong.