Learn R Programming

tinylens

The goal of tinylens is to provide a minimal set of tools for working with lenses in R.

As of the initial release, this is basically a re-implementation of the lenses package (https://github.com/cfhammill/lenses).

Installation

You can install the development version of tinylens from GitHub with:

# install.packages("pak")
pak::pak("arbelt/tinylens")

Example

The main benefit of lenses is that they are composable, and so allow for more streamlined transformations of nested data structures.

library(tinylens)
## basic example code

Copy Link

Version

Install

install.packages('tinylens')

Monthly Downloads

106

Version

0.1.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Albert Wang

Last Published

December 9th, 2024

Functions in tinylens (0.1.0)

where_il

Predicate ilens
over_map

Map a function over a list lens
map_l

Lens into a list or vector
attr_l

Attributes lens
filter_il

Filter ilens
c_l

Lens for accessing and modifying nested elements of a list or vector
%.%

Compose two lenses
indices_l

Subset lens
index_l

Index lens
lens

Create a lens
id_l

Identity lens
rows_l

Rows lens
view

View the focused part of a data structure
select_l

include verbs.R include lens.R Select lens
over

Modify the focused part of a data structure
names_l

Names lens
vec_data_l

Vector data lens
tinylens-package

tinylens: Minimal Implementation of Functional Lenses
set

Set the focused part of a data structure
slice_l

Slice lens