Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

jeanmathieupotvin/blueprint

Repository files navigation

Blueprint

Blueprint provides R6 classes that generate convenient data schemas. It is a tidy unopiniotated interface that aims to work with any kind of R objects.


Yo, listen up here's a story

About a little guy

That lives in a blue world

And all day and all night

And everything he sees is just blue

Like him inside and outside

- Wise words from a true 90's classic (Eiffel 65, Blue).


What are data schemas?

A schema is a concise description of how an object (such a list, a data.frame or a vector) is structured. It dictates what it should contain and how it should be structured. Hence, the name of the package: blueprint. Schemas behave a little bit like promises: you declare bindings that will live in the future and provide a thorough description of them. In other words, they are future bindings with super-powers. But blueprints are more than that, they are also firm handshakes between developers and scientists that work together.

# Create an Atomic blueprint for a double vector
# of length 1000 to be bound to `rain` later.
bp_rain <- blueprint::Atomic$new(double(), "rain", 1000)$print()

# Alternatively, you could have used the Blueprinter operator.
bp_rain <- rain %bp% double(1000L)

> <Atomic blueprint [0.0.0.9002]>
>   <name:rain type:double length:1000>

# Write a convenient YAML representation of it.
bp_rain$as_yaml(
    file    = "bp_rain.yaml",
    headers = list(author = "JM Potvin", desc = "rain levels (mm) in Montreal"))

# Bind in the current environment.
bp_rain$bind()

# Compare candidates against a blueprint.
bp_rain$compare(integer(10L))  # FALSE
bp_rain$compare(double(1000L)) # TRUE
# bp_rain.yaml
source: R[v3.6.3]::blueprint[v0.0.0.9002]::Atomic$as_yaml()
author: JM Potvin
desc: rain levels (mm) in Montreal
Atomic:
  name: rain
  type: double
  length: 1000
  prototype: .na.real

Blueprint or blueprint?

Upper cases can be annoying. Grammar can be too. When referring to the package, use whatever you prefer between Blueprint or blueprint. Just keep in mind that blueprint is the namespace's true name and that Blueprint is its core super-class.

Installation

Blueprint is still at an early stage of its development cycle. Best is to not install and/or use it for now. Developers can explore development versions and test their features by installing from Github.

# If you want to test the development version here.
if (!require("remotes")) install.packages("remotes")
remotes::install_github("jeanmathieupotvin/blueprint")

Source and binary files of specific versions are also avalaible on Github.

Contributions

Blueprint is a personal project. Once it reaches a more mature state, I will gladly open the development process to everyone! You can definitely send me your ideas if you are interested in seeing this package grow.

Questions

Ask me any questions related to the package by sending an email to info@blueprint.potvin.xyz, by opening a public discussion or by opening an issue. Issues should be reserved for bugs and suggestions (including feedback).