Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonocarroll/vec
A New Vector Class With Added Functionality
https://github.com/jonocarroll/vec
Last synced: about 2 months ago
JSON representation
A New Vector Class With Added Functionality
- Host: GitHub
- URL: https://github.com/jonocarroll/vec
- Owner: jonocarroll
- License: gpl-3.0
- Created: 2024-09-27T08:00:32.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-09-27T23:25:05.000Z (4 months ago)
- Last Synced: 2024-11-26T23:38:02.230Z (about 2 months ago)
- Language: R
- Homepage: https://jonocarroll.github.io/vec/
- Size: 1020 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE.md
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# vec
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
The goal of vec is to reinvent the "vector" class with new and improved
functionality.## Installation
You can install the development version of {vec} like so:
``` r
# install.packages("remotes")
remotes::install_github("jonocarroll/vec")
```## Examples
{vec} provides a new class extending R's atomic vectors which enables some new
functionality.```{r example}
library(vec)
```### Subsetting via Functions
Along with some built-in vector operations such as `is_even()`, {vec} enables
subsetting with a function or formula, and in-place replacements with the same```{r}
x <- as_vec(1:10)
xx[~is_even(.)]
x[is_even]
x[is_even] <- 0
x
```See the [vignette](https://jonocarroll.github.io/vec/articles/functions.html)
for more details.### Rotating
While not specific to {vec}, this package provides a ring-buffer-like function
which rotates a vector through `n` positions```{r}
x <- as_vec(1:5)
xrotate(x, n = 1)
rotate(x, n = 2)
rotate(x, n = -1)
```## Other Use Cases
I'm interested in what else a new vector class could bring to R. Add an
[Issue](https://github.com/jonocarroll/vec) if you can think of one!