https://github.com/nt-williams/cabinets
:package: for custom file structure templates accessible in R sessions outside the ones they were created in.
https://github.com/nt-williams/cabinets
reproducible-research workflow workflow-automation
Last synced: 5 months ago
JSON representation
:package: for custom file structure templates accessible in R sessions outside the ones they were created in.
- Host: GitHub
- URL: https://github.com/nt-williams/cabinets
- Owner: nt-williams
- License: other
- Created: 2019-09-12T21:06:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-10T00:56:13.000Z (over 4 years ago)
- Last Synced: 2024-04-24T20:13:53.903Z (about 1 year ago)
- Topics: reproducible-research, workflow, workflow-automation
- Language: R
- Homepage:
- Size: 264 KB
- Stars: 20
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- jimsghstars - nt-williams/cabinets - :package: for custom file structure templates accessible in R sessions outside the ones they were created in. (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# cabinets
[](https://CRAN.R-project.org/package=cabinets)

[](https://www.tidyverse.org/lifecycle/#stable)
[](https://codecov.io/gh/nt-williams/cabinets?branch=master)
[](https://github.com/nt-williams/cabinets/actions)Reproducibility can be tedious, **cabinets** makes it easier! **cabinets** creates project specific file structure templates that can be referenced at the start of any R session. These templates can then be used to initiate future projects with the option for them to be initiatied with a git repository. **cabinets** works by writing project specific file templates to the .Rprofile file of the default working directory. Doing so allows the templates to be accessed in new R sessions without having to redefine them.
**cabinets** has two main functions: `create_cabinet()` and `new_cabinet_proj()`. `create_cabinet()` constructs an R6 object of class `FileCabinet` which is then written to a .Rprofile file. At the start of fresh R sessions, the .Rprofile file loads the previously created cabinets for further use. `new_cabinet_proj()` can then be used to create future projects based on a cabinet template. Projects have the option of being created with an RStudio project and a git repository.
Users will be prompted for explicit permission to write to .Rprofile on first use. Permission to write can be revoked at any time by setting the permission option in the .Rprofile file to `FALSE`. Due to these explicit permission requirements, **cabinets** will only work in interactive R sessions.
## Installation
You can install the released version of **cabinets** from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("cabinets")
```And the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("nt-williams/cabinets@dev")
```## Motivation
Different organizations, research groups, projects, etc. have different standard directories. One organization might have the standard file structure:
```
├── data
│ ├── derived
│ └── source
├── code
├── reports
├── documents
└── log
```While another uses a structure like this:
```
├── Code
│ ├── ReportsCode
│ └── AnalysisCode
├── Notes
└── Log
```**cabinets** makes it easy to define these templates once and then call them for use whenever starting new projects in R.
## Example
A cabinet has three components: a name, a location, and a file structure. The location defines where new directories will be created from a cabinet template. The file structure defines, well, the structure of this directory. We use a list to define the structure, where the name of each list index is a unique relative path within the new directory. Using the first project file structure described above, lets create a new cabinet.
``` r
loc <- "~/Desktop"file_str <- list(
'data' = NULL,
'code' = NULL,
'data/derived' = NULL,
'data/source' = NULL,
'reports' = NULL,
'documents' = NULL,
'log' = NULL
)create_cabinet(name = "contract",
directory = loc,
structure = file_str)
#> ✓ Checking for permissions
#> ✓ Checking for .Rprofile
#> ✓ Checking cabinet name
#> ✓ Cabinet .contract created
#> ● Restart R for changes to take effect
#> ● Cabinet can be called with .contract
```The cabinet is now created and doesn't have to be redefined in future R sessions. To examine the cabinet we just call it.
``` r
.contract#> Cabinet name: contract
#> Cabinet path: ~/Desktop
#> Cabinet structure:
#> ├── data
#> │ ├── derived
#> │ └── source
#> ├── code
#> ├── reports
#> ├── documents
#> └── log
````new_cabinet_proj()` is then used to create a new directory from a cabinet template.
``` r
new_cabinet_proj(cabinet = .contract,
project_name = "project",
git = TRUE,
git_ignore = "data",
renv = TRUE)
```## Similar implementations
Similar implementations exist elsewhere. **cabinets** is unique for giving the user the ability to design their own project templates. These are all great packages, use what's best for you!
* [workflowr](https://github.com/jdblischak/workflowr)
* [projects](https://github.com/NikKrieger/projects)
* [starters](https://github.com/lockedata/starters)
* [ProjectTemplate](https://github.com/KentonWhite/ProjectTemplate)## Contributing
Please note that the **cabinets** project is released with a
[Contributor Code of Conduct](CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.