{"id":14068411,"url":"https://github.com/decisionpatterns/sticky","last_synced_at":"2025-10-21T20:17:02.877Z","repository":{"id":56936451,"uuid":"58513503","full_name":"decisionpatterns/sticky","owner":"decisionpatterns","description":"Persist attributes through data manipulations","archived":false,"fork":false,"pushed_at":"2020-03-17T01:45:37.000Z","size":55,"stargazers_count":21,"open_issues_count":8,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-09-26T06:58:22.114Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/decisionpatterns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-11T04:08:57.000Z","updated_at":"2024-03-31T14:25:55.000Z","dependencies_parsed_at":"2022-08-21T01:10:26.244Z","dependency_job_id":null,"html_url":"https://github.com/decisionpatterns/sticky","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decisionpatterns%2Fsticky","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decisionpatterns%2Fsticky/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decisionpatterns%2Fsticky/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decisionpatterns%2Fsticky/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decisionpatterns","download_url":"https://codeload.github.com/decisionpatterns/sticky/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228082276,"owners_count":17866601,"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-13T07:06:09.554Z","updated_at":"2025-10-21T20:16:57.819Z","avatar_url":"https://github.com/decisionpatterns.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"## Sticky: Persistent Attributes\n\n\u003c!--- [![License](https://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/gpl-2.0.html) --\u003e \n[![CRAN_Status_Badge](https://r-pkg.org/badges/version/sticky)](https://cran.r-project.org/package=sticky)\n[![Downloads](https://cranlogs.r-pkg.org/badges/sticky?color=brightgreen)](https://r-pkg.org/pkg/sticky)\n[![](http://cranlogs.r-pkg.org/badges/grand-total/sticky)](https://CRAN.R-project.org/package=sticky)\n[![software impact](http://depsy.org/api/package/r/sticky/badge.svg)](http://depsy.org/package/r/sticky)\n\u003c!-- badges: start --\u003e\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)\n\u003c!-- badges: end --\u003e\n\nIn base R, objects lose attributes in many common operations such as: subset, [, [[\u003c-, append, etc. or when inserted into or extracted from recursive (list-like) objects such as data frames or data tables. Marking objects 'sticky', make attributes resilient to these operations. In essence, sticky makes object behave more like objects in other languages whose attributes are preserved. There isn't much to the package. `sticky`/`unstick`and `sticky_all` are the only interfaces to the package.\n\n\n## Key Functions\n\n - `sticky`: make an objects attributes persist across data operations\n \n - `unstick`: remove the stickiness of an object; attributes will no longer \n   persist during common data operations\n\n - `sticky_all` : make all elements of a recursive object (e.g list, data frames, etc.) sticky.\n \n\n## Example\n\nHere is an simple example of a sticky attribute in action. Under base R, \nattributes do not survive a slice/subset/`[` operation: \n\n    x \u003c- 1:5\n    attr(x, 'foo') \u003c- 'bar'\n    attr(x[1:3],'foo')        # NULL -- attribute removed \n\nTo ensure that they get preserved, simply declare the object as `sticky`:\n\n    x \u003c- sticky(x)\n    attr(x[1:3],'foo')        # 'bar' -- attribute preserved    \n\n`sticky()` works for vectors inside table-like objects ( i.e. data.frames \nand data.tables), preserving their attributes during table operations.\n\n    df \u003c- data.frame( \n      sticky   = sticky( structure(1:5, foo=\"bar\") ),\n      nonstick = structure( letters[1:5], foo=\"baz\" )\n    )\n    attr( df[2:3,\"nonstick\"], 'foo' )  # NULL\n    attr( df[2:3,\"sticky\"], 'foo' )    # bar\n    \n    \nIf all elements of a list or a data.frame need to behave in a sticky manner, \nuse `sticky_all`. \n\n    df \u003c- sticky_all(df)\n    attr( df[2:3,\"nonstick\"], 'foo' )  # Now 'baz'\n\n\n\n## Installation \n\n### Stable Version: CRAN (coming soon)\n\n    install.packages('sticky')\n\n### Development Version: Github\n\n    library(devtools)\n    lnstall_github('decisionpatterns/sticky')\n\n\n## Use Cases\n\nThere are a number of things that can be done with `sticky`:\n\n * Preserve attributes of atomic or recursive objects\n * Ensure that attributes of vectors in data.[frame|table] are preserved\n * Build a basic class system.\n\n\n## References\n\nThe issue of attribute resilience has been often asked and debated. Here are a \nfew of the most prevalent discussions.\n\n- [loss-of-attributes-despite-attempts-to-preserve-them](https://stackoverflow.com/questions/23991060/loss-of-attributes-despite-attempts-to-preserve-them)\n- [how-to-delete-a-row-from-a-data-frame-without-losing-the-attributes](https://stackoverflow.com/questions/10404224/how-to-delete-a-row-from-a-data-frame-without-losing-the-attributes)\n- [approaches-to-preserving-objects-attributes-during-extract-replace-operations](https://stackoverflow.com/questions/23841387/approaches-to-preserving-objects-attributes-during-extract-replace-operations)\n- [indexing-operation-removes-attributes](https://stackoverflow.com/questions/13432519/indexing-operation-removes-attributes)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecisionpatterns%2Fsticky","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecisionpatterns%2Fsticky","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecisionpatterns%2Fsticky/lists"}