README.md

debvctrs

This tutorial package is meant to go along with my talk vctrs: Creating custom vector classes with the vctrs package at RStudio::conf 2020. Slides from the talk are available here.

debvctrs is an example package to demonstrate the creation of new S3 vector classes using the vctrs package. debvctrs is based on the more complete debkeepr package that integrates non-decimal currencies that use the tripartite system of pounds, shillings, and pence into R. This package is not meant for analytical use, though all aspects of the package work as expected and are fully tested using testthat.

Installation

You can install debvctrs from GitHub with remotes:

# install.packages("remotes")
remotes::install_github("jessesadler/debvctrs")

Usage

The debvctrs package demonstrates the process for creating two different types of S3-vector classes or types. The deb_decimaltype represents non-decimal currencies in decimalized form and is based on a double vector. It has two attributes: a unit attribute to record whether the values represent pounds, shillings, or pence and a bases attribute to determine the bases of the shillings and pence units. The deb_lsd type uses the record style to maintain the tripartite structure of non-decimal currencies. A record-style vector uses a list of equal-length vectors to designate the components that make up each vector. Like the deb_decimal type, deb_lsd has a bases attribute. For a more thorough introduction to the structure of the two classes and the use of the classes, see the description from the debkeepr package.

The R scripts for the package provide an order for constructing these two S3 vectors with vctrs. This tutorial is based on the S3 vignette from the vctrs package. It will be useful to work through this tutorial with the explanations from the vignette.

Resources



jessesadler/debvctrs documentation built on June 14, 2021, 6:36 a.m.