{"id":13857809,"url":"https://github.com/r-lib/rray","last_synced_at":"2025-04-22T00:31:38.555Z","repository":{"id":49070183,"uuid":"154700386","full_name":"r-lib/rray","owner":"r-lib","description":"Simple Arrays","archived":false,"fork":false,"pushed_at":"2021-10-27T22:39:56.000Z","size":2175,"stargazers_count":130,"open_issues_count":45,"forks_count":12,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-31T15:25:37.197Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rray.r-lib.org","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r-lib.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-25T16:08:05.000Z","updated_at":"2024-12-29T18:59:20.000Z","dependencies_parsed_at":"2022-09-24T01:51:41.856Z","dependency_job_id":null,"html_url":"https://github.com/r-lib/rray","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Frray","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Frray/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Frray/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Frray/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-lib","download_url":"https://codeload.github.com/r-lib/rray/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250157799,"owners_count":21384331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-05T03:01:47.601Z","updated_at":"2025-04-22T00:31:38.235Z","avatar_url":"https://github.com/r-lib.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\neditor_options: \n  chunk_output_type: console\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# rray \u003ca href='https:/rray.r-lib.org'\u003e\u003cimg src='man/figures/logo.png' align=\"right\" height=\"139\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)\n[![Travis build status](https://travis-ci.org/r-lib/rray.svg?branch=master)](https://travis-ci.org/r-lib/rray)\n[![Codecov test coverage](https://codecov.io/gh/r-lib/rray/branch/master/graph/badge.svg)](https://codecov.io/gh/r-lib/rray?branch=master)\n\u003c!-- badges: end --\u003e\n\nrray (said: \"r-ray\") is an array manipulation library for R. It has three main goals:\n\n- To provide an rray class that tries to be stricter and more consistent than base R arrays, similar in spirit to tibble.\n- To support broadcasting throughout the package, which allows for novel yet intuitive array operations that have been missing from the R ecosystem.\n- To provide a consistent, powerful toolkit for array based manipulation, usable by both the new rray objects and base R matrices/arrays.\n\nA set of slides, presented by Davis Vaughan at useR! 2019, introducing the package and showing its utility can be found on [speakerdeck](https://speakerdeck.com/davisvaughan/user-2019-rray). \n\nView the vignettes for each goal on [the website](https://rray.r-lib.org) to learn more about how to use rray. \n\n- `vignette(\"the-rray\")`\n- `vignette(\"broadcasting\")`\n- `vignette(\"toolkit\")`\n\n```{r}\nlibrary(rray)\n```\n\n\n\n## What can it do?\n\nIn short, rray tries to make array manipulation in R more intuitive by combining the idea of broadcasting with knowing when to _not_ drop dimensions. This results in operations such as:\n\n```{r}\nx \u003c- rray(1:6, dim = c(3, 2))\n\n# Compute proportions along the 1st dimension\nx / rray_sum(x, axes = 1)\n\n# Equivalent base R syntax\nsweep(x, 2, apply(x, 2, sum), \"/\")\n```\n\nThese concepts are baked into every part of rray, and show up in other functions such as `rray_bind()`. Using broadcasting, `rray_bind()` can bind arrays together in ways that base R cannot with the native `cbind()` and `rbind()` functions.\n\n```{r, error=TRUE}\na \u003c- array(c(1, 2), dim = c(2, 1))\nb \u003c- array(c(3, 4), dim = c(1, 2))\n\na\n\nb\n\n# Error\ncbind(a, b)\n\n# `a` is first broadcast to have dimensions: (2, 2)\nrray_bind(a, b, .axis = 1)\n\n# Error\nrbind(a, b)\n\n# `b` is first broadcast to have dimensions: (2, 2)\nrray_bind(a, b, .axis = 2)\n```\n\n## Installation\n\nYou can install from CRAN with:\n\n```{r, eval = FALSE}\ninstall.packages(\"rray\")\n```\n\n\nYou can install the development version from Github with:\n\n```{r, eval = FALSE}\nremotes::install_github(\"r-lib/rray\")\n```\n\n## Acknowledgements\n\nrray would not be possible without the underlying C++ library, [`xtensor`](https://github.com/QuantStack/xtensor). Additionally, rray uses a large amount of the infrastructure in [`vctrs`](https://github.com/r-lib/vctrs) to be as consistent and type stable as possible. \n\n## Alternatives\n\nThe Matrix package implements a small subset of column-wise broadcasting operations. rray fully supports broadcasting in all operations.\n\nThe original motivation for this package, and even for xtensor, is the excellent Python library, NumPy. As far as I know, it has the original implementation of broadcasting, and is a core library that a huge number of others are built on top of.\n\nIn the past, the workhorse for flexibly binding arrays together has been the abind package. This package has been a great source of inspiration and has served as a nice benchmark for rray.\n\n## Notes\n\nCurrently, rray does not handle missing values in arithmetic operations and the reducing functions. This is coming, as the underlying library xtensor natively supports missing values, however a few upstream bugs are currently preventing rray from using those features.\n\nrray will perform best on R 3.6.0 and above. It is able to take advantage of a few of the ALTREP features there, which result in less copies being made per function call.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Frray","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-lib%2Frray","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Frray/lists"}