{"id":14067612,"url":"https://github.com/rossellhayes/crossmap","last_synced_at":"2026-03-09T19:38:26.222Z","repository":{"id":43386891,"uuid":"276334463","full_name":"rossellhayes/crossmap","owner":"rossellhayes","description":"❌🗺 Apply Functions to All Combinations of List Elements","archived":false,"fork":false,"pushed_at":"2023-01-12T23:30:00.000Z","size":929,"stargazers_count":20,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T22:13:35.897Z","etag":null,"topics":["functional-programming","r","rstats","tidyverse"],"latest_commit_sha":null,"homepage":"https://crossmap.rossellhayes.com","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/rossellhayes.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-01T09:26:59.000Z","updated_at":"2024-11-19T13:32:58.000Z","dependencies_parsed_at":"2023-02-09T13:46:50.380Z","dependency_job_id":null,"html_url":"https://github.com/rossellhayes/crossmap","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossellhayes%2Fcrossmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossellhayes%2Fcrossmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossellhayes%2Fcrossmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossellhayes%2Fcrossmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rossellhayes","download_url":"https://codeload.github.com/rossellhayes/crossmap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244751609,"owners_count":20504242,"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":["functional-programming","r","rstats","tidyverse"],"created_at":"2024-08-13T07:05:41.390Z","updated_at":"2026-03-09T19:38:26.218Z","avatar_url":"https://github.com/rossellhayes.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\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# remotes::install_github(\"GuangchuangYu/badger\")\nlibrary(badger)\n```\n\n# crossmap \u003cimg src=\"man/figures/logo.png?raw=TRUE\" align=\"right\" height=\"138\" /\u003e\n\n\u003c!-- badges: start --\u003e\n`r badge_cran_release(color = \"brightgreen\")`\n[![crossmap status badge](https://rossellhayes.r-universe.dev/badges/crossmap)](https://rossellhayes.r-universe.dev)\n`r badge_lifecycle(\"stable\")`\n`r badge_license(color = \"blueviolet\")`\n`r badge_github_actions(action = \"R-CMD-check\")`\n`r badge_codecov()`\n`r badge_codefactor()`\n\u003c!-- badges: end --\u003e\n\n**crossmap** provides an extension to [**purrr**](https://github.com/tidyverse/purrr)'s family of mapping functions.\n`xmap()` works like `purrr::pmap()`, but applies a function to every combination of elements in a list of inputs.\n\n**crossmap** also includes a few other general purpose and specialized  functions for working with combinations of list elements.\n\n## Installation\n\nYou can install the released version of **crossmap** from [CRAN](https://cran.r-project.org/package=crossmap) with:\n\n``` {r eval = FALSE}\ninstall.packages(\"crossmap\")\n```\n\nor the development version from [GitHub](https://github.com/rossellhayes/crossmap) with:\n\n```{r eval = FALSE}\n# install.packages(\"pak\")\npak::pkg_install(\"rossellhayes/crossmap\")\n```\n\n## Usage\n\n```{r include = FALSE}\nlibrary(dplyr)\nlibrary(purrr)\nlibrary(crossmap)\n```\n\nWhile `purrr::pmap()` applies a function to list elements pairwise, `xmap()` applies a function to all combinations of elements.\n\n```{r}\npmap_chr(list(1:3, 1:3), ~ paste(.x, \"*\", .y, \"=\", .x * .y))\nxmap_chr(list(1:3, 1:3), ~ paste(.x, \"*\", .y, \"=\", .x * .y))\n```\n\n`xmap_mat()` formats `xmap()` results into a matrix.\n\n```{r}\nxmap_mat(list(1:3, 1:6), prod)\n```\n\n**crossmap** also integrates with [**furrr**](https://github.com/futureverse/furrr) to offer parallelized versions of the `xmap()` functions.\n\n```{r}\nfuture::plan(\"multisession\")\nfuture_xmap_chr(list(1:3, 1:3), ~ paste(.x, \"*\", .y, \"=\", .x * .y))\n```\n\n`cross_fit()` is an easy wrapper for an important use of **crossmap**, crossing model specifications with different formulas, subsets, and weights.\n\n```{r warning = FALSE}\ncross_fit(\n  mtcars,\n  formulas = list(hp = mpg ~ hp, drat = mpg ~ drat),\n  cols     = c(cyl, vs),\n  weights  = c(wt, NA)\n)\n```\n\n`cross_list()` finds all combinations of elements from a set of lists.\n\n```{r}\ncross_list(number = 1:3, letter = letters[1:3])\ncross_tbl(number = 1:3, letter = letters[1:3])\n```\n\nAnd `cross_join()` finds all combinations of the rows of data frames.\n\n```{r}\ncross_join(\n  tibble(\n    color = c(\"red\", \"yellow\", \"orange\"),\n    fruit = c(\"apple\", \"banana\", \"cantaloupe\")\n  ),\n  tibble(dessert = c(\"cupcake\", \"muffin\", \"streudel\"), makes = c(8, 6, 1))\n)\n```\n\n`map_vec()` and variants automatically determine output types.\nThis means you don't have to worry about adding `_int()`, `_dbl()` or `_chr()`.\n\n```{r}\nmap_vec(sample(5), ~ . ^ 2)\nmap_vec(c(\"apple\", \"banana\", \"cantaloupe\"), paste0, \"s\")\n```\n\n---\n\nHex sticker font is [Source Sans by Adobe](https://github.com/adobe-fonts/source-sans).\n\nPlease note that **crossmap** is released with a [Contributor Code of Conduct](https://www.contributor-covenant.org/version/2/0/code_of_conduct/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frossellhayes%2Fcrossmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frossellhayes%2Fcrossmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frossellhayes%2Fcrossmap/lists"}