vctrs: Creating custom vector classes with the vctrs package
summary
vctrs provides a reproducible path to make S3 vector classes that keep non‑decimal currencies as structured triples (pounds, shillings, pence) instead of forcing decimalization. The demo builds deb_lsd and deb_decimal classes (record-style list vectors and double-backed decimals), implements normalization (compound-unit remainder division), and defines coercion with vec_ptype2 and casting to convert and compare mixed types. Works with tibbles; record vectors still have some mutate rough edges. vctrs deb_lsd vec_ptype2
AI-written summary · about
chapters (18)
- 0:00Introduction
- 0:31What I do
- 1:43Problem space
- 5:20What do I need to do
- 6:40Goals of vctrs
- 7:02Benefits of vctrs
- 7:27Outline of the talk
- 8:42Overview of the steps
- 9:16Overview of vctrs
- 10:03design considerations
- 11:27simplified vector class
- 12:54Implementing the class
- 14:03Casting and coercion
- 14:26Casting and coercion workflow
- 15:20Design choices
- 15:53Casting
- 16:57Combining
- 18:17Questions
related talks
41m“Avoiding Disasters with Strongly Typed C++”
01h 05mA C++ Approach to Physical Units
58mSimplify and Secure Equation Systems with Type-Driven Development
01h 31mThe C++ Vector Challenge
01h 02m“How to Choose the Right Standard Library Container, and Why You Should Want Some More”
58mRust Traits In C++
29mSingle Value Objects: where DDD and Functional Programming Share Forces
01h 31mImproving Our Safety With a Modern C++ Quantities and Units Library
