Elektrine lite

← Feed

@djnavarro@fosstodon.org

Post #1891071

2023-08-08 06:51 UTC

A smol blog post about writing assertions in #rstats data pipelines. It's not the sexiest topic in the world, but oh my have I learned the hard way that it's an important one https://blog.djnavarro.net/being-assertive/

Replies (6)

  • @jimgar@fosstodon.org 2023-08-08 07:32

    @djnavarro@fosstodon.org Awesome post, I think I have lots to learn from this, especially about the tabular data at the end. One addition if I may: stopifnot can produce informative messages. You have to provide it in the named arg way, like stopifnot(“Value is not scalar” = length(value) == 1) I’ve been using this method for asserting that inputs to functions are robustly checked. It can get ugly. But there’s no package dependencies… but maybe a minimum R version 🤔 I can’t remember when it was introduced.

    Open ##2951153

  • @djnavarro@fosstodon.org you just forgot to mention the best package in this subject: checkmate

    Open ##2951158

  • @modrak_m@fediscience.org 2023-08-08 11:02

    @djnavarro@fosstodon.org 100%!!! As a shameless plug, a long time ago I wrote a short post about a similar topic, with verifying joins as an example: https://www.martinmodrak.cz/2018/09/17/tests-in-r-markdown/ Now that dplyr joins support those checks internally via the `unmatched`, `multiple` and `relationship` arguments there's even less reason to not doing those checks... People, check you joins!

    Open ##2951163

  • @milesmcbain@fosstodon.org 2023-08-08 11:18

    @djnavarro@fosstodon.org I enjoy testthat in this role due to assertion failure detail

    Open ##2951165

  • @brianrepko@hachyderm.io 2023-08-08 18:52

    @djnavarro@fosstodon.org This is awesome - I'm currently using `{checkmate}`which is mentioned in the "three other packages for this but a girl only has so many rhymes in her" category.

    Open ##2951171

  • @djnavarro@fosstodon.org Engaging writing on a super important issue. I’m too unskilled to follow the details well, but the core argument is compelling.

    Open ##2951173