Guru's Verification engine ensures consistency, confidence, and trust in the knowledge your organization shares. Learn more.

R | ALTREP Framework

The ALTREP ("alternative representation") framework [1] for R is a way for packages to customize the underlying implementation of basic R objects (e.g. vectors), while ostensibly keeping their behavior in R exactly the same. This gives packages more flexibility when processing data while not changing how R code works from the package user's perspective.

For example, in base R, all values of vectors are held in memory, but with this framework, a package can instead have the in-memory representation of the vector point to a location in the hard disk where the value is held, and only read in the data when it's needed.

In theory, any data using ALTREP to behave identically as their non-ALTREP counterparts when used in code. However, in practice some differences will leak out, especially when it comes to memory usage and error detection. See [2] for an example in the vroom package.

Resources:

You must have Author or Collection Owner permission to create Guru Cards. Contact your team's Guru admins to use this template.