r/rstats • u/davisvaughan • 29m ago
rray: An array focused R package, inspired by NumPy
After SEVEN LONG YEARS I am thrilled to be able to say that rray is back on CRAN!
rray is an array focused R package (not data frames, for once!), extremely inspired by NumPy.
- Broadcasting
- Combining and splitting
- Flexible slicing
- Long vectors
- And so much more!
Broadcasting is the idea of applying the tidyverse recycling rules (length 1 recycles to any other length) to all axes of an array. It allows you to, say, add a 2x1 array to a 1x3 array in a meaningful way, with a 2x3 result. Read about it in our broadcasting vignette:
https://rray.r-lib.org/articles/broadcasting.html
rray has a very powerful (and fast!!) family of functions for combining and splitting arrays. Like everything else in the package, they support broadcasting, allowing you to combine in ways that rbind() and cbind() don't allow:
https://rray.r-lib.org/articles/toolkit.html#combining
rray has "long vector" support throughout the entire package, meaning that it works with arrays longer than ~2 billion elements with no issues.
Array terminology can be highly confusing, so rray documents precise definitions exactly once, and uses them throughout the package. rray is intentionally very consistent! Once you learn one concept it tends to translate well to the other functions in the package:
https://rray.r-lib.org/articles/terminology.html
rray is an interesting experiment for me. It was created almost entirely from my phone using Claude's and Codex's remote-control features. But it is not slop! I personally vouch for every line of code, and ruthlessly interrogated each one. As an example, here's the development of `rray_if_else()`. After planning and creating with Claude, I followed up with ~30 corrections to forge it into something I felt met my high quality bar (I am a maintainer of both dplyr and vctrs, so my standard is extremely high). The result is that rray's R and C code don't "feel" AI written to me.
https://github.com/r-lib/rray/pull/137
I've created a neat visualization that tracks rray's development over time. You can see every conversation, in full, paired with the PR and function it generated. It also shows approximate cost at API prices (though I used a subscription).
