Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
psanker committed Apr 30, 2024
1 parent b2e4293 commit 9d85509
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 64 deletions.
51 changes: 30 additions & 21 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ knitr::opts_chunk$set(
)
```

# blueprintr <img src="man/figures/logo.png" align="right" height="139" />
# blueprintr <img src="man/figures/logo.png" style="float:right; width:139px" />

> blueprintr is a plugin to [drake](https://github.com/ropensci/drake) 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.
> 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)
Expand All @@ -25,59 +25,68 @@ knitr::opts_chunk$set(

## Usage

Define blueprints of your data using `blueprint()`. Blueprints combine drake target commands with some extra metadata about the output tabular dataset, including the name and description of the data.
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}
library(blueprintr)
blueprint1 <- blueprint(
```{r, eval=FALSE}
# blueprints/blueprint1.R
blueprint(
"blueprint1",
description = "My first blueprint",
command = {
# Put all code related to building this dataset here
mtcars
}
)
blueprint1
```

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.
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)
command = .TARGET("blueprint1") %>%
filter(cyl == 4)
)
```

Once all blueprints are defined, attach them to a plan using `attach_blueprint()` or `attach_blueprints()` so drake can run the needed tasks.
Once all blueprints are defined, add them to your `_targets.R` pipeline file:

```{r, eval=FALSE}
library(magrittr)
library(drake)
# _targets.R
library(targts)
library(blueprintr)
plan_from_blueprint(blueprint1) %>%
attach_blueprint(blueprint2)
list(
# ... Other steps ...
tar_blueprints()
)
```

drake handles the code execution based on the targets generated by blueprintr.
targets handles the code execution based on the steps generated by blueprintr.

## Installation

As blueprintr is not yet on CRAN, you must install the package from this repository:
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
```r
install.packages("remotes")
remotes::install_github("nyuglobalties/blueprintr")
```
Expand Down
82 changes: 39 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# blueprintr <img src="man/figures/logo.png" align="right" height="139" />
# blueprintr <img src="man/figures/logo.png" style="float:right; width:139px" />

> blueprintr is a plugin to [drake](https://github.com/ropensci/drake)
> 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.
> 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 -->

Expand All @@ -21,81 +22,76 @@ status](https://www.r-pkg.org/badges/version/blueprintr)](https://CRAN.R-project
## Usage

Define blueprints of your data using `blueprint()`. Blueprints combine
drake target commands with some extra metadata about the output tabular
dataset, including the name and description of the data.
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
library(blueprintr)

blueprint1 <- blueprint(
# blueprints/blueprint1.R
blueprint(
"blueprint1",
description = "My first blueprint",
command = {
# Put all code related to building this dataset here
mtcars
}
)

blueprint1
#> <blueprint: 'blueprint1'>
#>
#> Description: My first blueprint
#> Annotations: DISABLED
#> Metadata location: '/Users/patrickanker/dev/blueprintr/blueprints/blueprint1.csv'
#>
#> -- Command --
#> Workflow command:
#> {
#> mtcars
#> }
#>
#> Raw command:
#> {
#> 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.
metadata files. You can store these tests in the conventional “R”
folder:

``` r
# R/checks.R
no_missing_cyl <- function(df) {
all(!is.na(df$cyl))
}
```

``` r
# 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)
command = .TARGET("blueprint1") %>%
filter(cyl == 4)
)
```

Once all blueprints are defined, attach them to a plan using
`attach_blueprint()` or `attach_blueprints()` so drake can run the
needed tasks.
Once all blueprints are defined, add them to your `_targets.R` pipeline
file:

``` r
library(magrittr)
library(drake)
# _targets.R
library(targts)
library(blueprintr)

plan_from_blueprint(blueprint1) %>%
attach_blueprint(blueprint2)
list(
# ... Other steps ...
tar_blueprints()
)
```

drake handles the code execution based on the targets generated by
targets handles the code execution based on the steps generated by
blueprintr.

## Installation

As blueprintr is not yet on CRAN, you must install the package from this
repository:
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")
Expand Down

0 comments on commit 9d85509

Please sign in to comment.