-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
96 lines (74 loc) · 3.05 KB
/
README.Rmd
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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# blueprintr <img src="man/figures/logo.png" align="right" width="139" />
> blueprintr is a companion to [targets](https://github.com/ropensci/targets) that adds automated steps for tabular dataset documentation and testing. Designed for social science research projects, this package creates a framework to build trust in your data and to prevent programming issues from affecting your analysis results.
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/blueprintr)](https://CRAN.R-project.org/package=blueprintr)
[![R-CMD-check](https://github.com/nyuglobalties/blueprintr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/nyuglobalties/blueprintr/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
## Usage
Define blueprints of your data using `blueprint()`. Blueprints combine dataset creation code with some extra metadata about the output tabular dataset, including the name and description of the data. By convention, these blueprint calls are stored in scripts in the "blueprints" folder of your project:
```{r, eval=FALSE}
# blueprints/blueprint1.R
blueprint(
"blueprint1",
description = "My first blueprint",
command = {
# Put all code related to building this dataset here
mtcars
}
)
```
Refer to other datasets using `.TARGET()` to guarantee that parent datasets are also tested and documented. Run checks on the dataset entirely with the `checks` parameter and define variable tests in the metadata files. You can store these tests in the conventional "R" folder:
```{r, eval=FALSE}
# R/checks.R
no_missing_cyl <- function(df) {
all(!is.na(df$cyl))
}
```
```{r, eval=FALSE}
# blueprints/blueprint2.R
blueprint2 <- blueprint(
"blueprint2",
description = "My second blueprint that depends on another",
checks = check_list(
no_missing_cyl()
),
command = .TARGET("blueprint1") %>%
filter(cyl == 4)
)
```
Once all blueprints are defined, add them to your `_targets.R` pipeline file:
```{r, eval=FALSE}
# _targets.R
library(targts)
library(blueprintr)
list(
# ... Other steps ...
tar_blueprints()
)
```
targets handles the code execution based on the steps generated by blueprintr.
## Installation
Stable versions of blueprintr can be installed from Global TIES' r-universe:
```r
install.packages("blueprintr", repos = "https://nyuglobalties.r-universe.dev")
```
Development versions can be installed from this repository:
```r
install.packages("remotes")
remotes::install_github("nyuglobalties/blueprintr")
```
## Contributing
Please note that the 'blueprintr' project is released with a [Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.