{"id":16572271,"url":"https://github.com/jonocarroll/charcuterie","last_synced_at":"2025-03-16T20:31:22.248Z","repository":{"id":251447045,"uuid":"837240514","full_name":"jonocarroll/charcuterie","owner":"jonocarroll","description":"Handle Strings as Vectors of Characters","archived":false,"fork":false,"pushed_at":"2024-11-07T21:30:54.000Z","size":1331,"stargazers_count":26,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-09T20:34:32.230Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jonocarroll.github.io/charcuterie/","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/jonocarroll.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-02T14:07:24.000Z","updated_at":"2024-11-12T13:49:17.000Z","dependencies_parsed_at":"2024-08-07T14:16:03.391Z","dependency_job_id":"5c8c6a7e-df38-4fc7-b830-c9af7b9ae694","html_url":"https://github.com/jonocarroll/charcuterie","commit_stats":null,"previous_names":["jonocarroll/charcuterie"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Fcharcuterie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Fcharcuterie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Fcharcuterie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Fcharcuterie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonocarroll","download_url":"https://codeload.github.com/jonocarroll/charcuterie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243830912,"owners_count":20354848,"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-10-11T21:26:58.536Z","updated_at":"2025-03-16T20:31:21.563Z","avatar_url":"https://github.com/jonocarroll.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, 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# charcuterie \u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"136\" alt=\"\" /\u003e\n\n\u003c!-- badges: start --\u003e\n\u003c!-- badges: end --\u003e\n\nThe goal of {charcuterie} is to finally have strings as iterable character vectors.\n\n## Installation\n\nYou can install the published version from CRAN with\n\n``` r\ninstall.packages(\"charcuterie\")\n```\n\nYou can install the development version with\n\n``` r\n# install.packages(\"remotes\")\nremotes::install_github(\"jonocarroll/charcuterie\")\n```\n\n## Motivation\n\nSee this blog post: https://jcarroll.com.au/2024/08/03/charcuterie-what-if-strings-were-iterable-in-r/\n\nMost programming languages seem to treat a string as an array of characters, but \nnot R, where a \"string\" is an object of type \"character\" which has a length of 1. \nThe number of 'characters' in a string is obtained via `nchar(x)` but otherwise, \nthe individual 'characters' comprising the string are rarely exposed. \n\nThe most common route around this limitation is to split the string into smaller \nstrings, each containing a single character, i.e.\n\n```{r}\nstrsplit(\"string\", split = \"\")\n```\n\nwhich produces a list of strings, each a single character. This is cumbersome to\ntype out, so this package offers a cleaner approach (which does the above all\nthe same)\n\n```{r}\nlibrary(charcuterie)\ns \u003c- chars(\"string\")\ns\n```\n\nThis _looks like_ it did nothing, but that's the point - it still looks like a \n\"string\". It's actually a vector, though\n\n```{r}\nunclass(s)\n```\n\n## Example Usage\n\nThis means you can finally do vector things with it, like reverse it\n\n```{r}\nrev(s)\n```\n\nor sort it\n\n```{r}\nsort(s)\n```\n\nor index into it\n\n```{r}\ns[3]\n```\n\nor count elements\n\n```{r}\ncount(chars(\"strawberry\"), \"r\")\n```\n\n{charcuterie} defines S3 methods of functions for a wide range of operations to \nbe performed on a string built from a vector of characters\n\n- index with `[`\n- concatenate with `c`\n- print with `format` and `print`\n- slice with `head` and `tail`\n- reverse with `rev`\n- sort with `sort`\n- set operations with `setdiff`, `union`, `intersect`, and a new `except`\n- leverage existing vectorised operations like `unique`, `toupper`, and `tolower`\n\nFor more detailed usage examples, see the vignettes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonocarroll%2Fcharcuterie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonocarroll%2Fcharcuterie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonocarroll%2Fcharcuterie/lists"}