crossmap
❌🗺 Apply functions to all combinations of list elements in R
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.8%) to scientific vocabulary
Keywords
functional-programming
r
rstats
tidyverse
Last synced: 6 months ago
·
JSON representation
Repository
❌🗺 Apply functions to all combinations of list elements in R
Basic Info
- Host: GitHub
- Owner: rossellhayes
- License: other
- Language: R
- Default Branch: main
- Homepage: https://pkg.rossellhayes.com/crossmap
- Size: 1.74 MB
Statistics
- Stars: 21
- Watchers: 2
- Forks: 0
- Open Issues: 1
- Releases: 9
Topics
functional-programming
r
rstats
tidyverse
Created over 5 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Changelog
License
Code of conduct
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
# remotes::install_github("GuangchuangYu/badger")
library(badger)
```
# crossmap
`r badge_cran_release(color = "brightgreen")`
[](https://rossellhayes.r-universe.dev)
`r badge_lifecycle("stable")`
`r badge_license(color = "blueviolet")`
`r badge_github_actions(action = "R-CMD-check")`
`r badge_codecov()`
`r badge_codefactor()`
**crossmap** provides an extension to [**purrr**](https://github.com/tidyverse/purrr)'s family of mapping functions.
`xmap()` works like `purrr::pmap()`, but applies a function to every combination of elements in a list of inputs.
**crossmap** also includes a few other general purpose and specialized functions for working with combinations of list elements.
## Installation
You can install the released version of **crossmap** from [CRAN](https://cran.r-project.org/package=crossmap) with:
``` {r eval = FALSE}
install.packages("crossmap")
```
or the development version from [GitHub](https://github.com/rossellhayes/crossmap) with:
```{r eval = FALSE}
# install.packages("pak")
pak::pkg_install("rossellhayes/crossmap")
```
## Usage
```{r include = FALSE}
library(dplyr)
library(purrr)
library(crossmap)
```
While `purrr::pmap()` applies a function to list elements pairwise, `xmap()` applies a function to all combinations of elements.
```{r}
pmap_chr(list(1:3, 1:3), ~ paste(.x, "*", .y, "=", .x * .y))
xmap_chr(list(1:3, 1:3), ~ paste(.x, "*", .y, "=", .x * .y))
```
`xmap_mat()` formats `xmap()` results into a matrix.
```{r}
xmap_mat(list(1:3, 1:6), prod)
```
**crossmap** also integrates with [**furrr**](https://github.com/futureverse/furrr) to offer parallelized versions of the `xmap()` functions.
```{r}
future::plan("multisession")
future_xmap_chr(list(1:3, 1:3), ~ paste(.x, "*", .y, "=", .x * .y))
```
`cross_fit()` is an easy wrapper for an important use of **crossmap**, crossing model specifications with different formulas, subsets, and weights.
```{r warning = FALSE}
cross_fit(
mtcars,
formulas = list(hp = mpg ~ hp, drat = mpg ~ drat),
cols = c(cyl, vs),
weights = c(wt, NA)
)
```
`cross_list()` finds all combinations of elements from a set of lists.
```{r}
cross_list(number = 1:3, letter = letters[1:3])
cross_tbl(number = 1:3, letter = letters[1:3])
```
And `cross_join()` finds all combinations of the rows of data frames.
```{r}
cross_join(
tibble(
color = c("red", "yellow", "orange"),
fruit = c("apple", "banana", "cantaloupe")
),
tibble(dessert = c("cupcake", "muffin", "streudel"), makes = c(8, 6, 1))
)
```
`map_vec()` and variants automatically determine output types.
This means you don't have to worry about adding `_int()`, `_dbl()` or `_chr()`.
```{r}
map_vec(sample(5), ~ . ^ 2)
map_vec(c("apple", "banana", "cantaloupe"), paste0, "s")
```
---
Hex sticker font is [Source Sans by Adobe](https://github.com/adobe-fonts/source-sans).
Please note that **crossmap** is released with a [Contributor Code of Conduct](https://www.contributor-covenant.org/version/2/0/code_of_conduct/).
Owner
- Name: Alex Rossell Hayes
- Login: rossellhayes
- Kind: user
- Location: Davis, California
- Company: Posit Software, PBC
- Repositories: 12
- Profile: https://github.com/rossellhayes
Data Science Educator at @rstudio | Political Science PhD Candidate at UCLA
GitHub Events
Total
- Create event: 1
- Release event: 1
- Issues event: 6
- Watch event: 1
- Issue comment event: 2
- Push event: 20
Last Year
- Create event: 1
- Release event: 1
- Issues event: 6
- Watch event: 1
- Issue comment event: 2
- Push event: 20
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Alex Rossell Hayes | a****r@r****m | 136 |
| Alex Rossell Hayes | 4****s | 3 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 7
- Total pull requests: 4
- Average time to close issues: 19 days
- Average time to close pull requests: about 20 hours
- Total issue authors: 4
- Total pull request authors: 1
- Average comments per issue: 1.57
- Average comments per pull request: 1.0
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 3
- Pull requests: 0
- Average time to close issues: about 1 month
- Average time to close pull requests: N/A
- Issue authors: 2
- Pull request authors: 0
- Average comments per issue: 0.67
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- rossellhayes (3)
- hadley (2)
- ramiromagno (1)
- lionel- (1)
Pull Request Authors
- rossellhayes (4)
Top Labels
Issue Labels
enhancement (1)
Pull Request Labels
enhancement (3)
Packages
- Total packages: 1
-
Total downloads:
- cran 616 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 7
- Total maintainers: 1
cran.r-project.org: crossmap
Apply Functions to All Combinations of List Elements
- Homepage: https://crossmap.rossellhayes.com
- Documentation: http://cran.r-project.org/web/packages/crossmap/crossmap.pdf
- License: MIT + file LICENSE
-
Latest release: 0.4.2
published 10 months ago
Rankings
Stargazers count: 13.3%
Forks count: 28.8%
Average: 29.3%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Downloads: 39.0%
Maintainers (1)
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- backports * imports
- cli * imports
- dplyr >= 1.0.0 imports
- generics * imports
- purrr * imports
- rlang * imports
- stats * imports
- utils * imports
- broom * suggests
- covr * suggests
- crayon * suggests
- estimatr * suggests
- furrr * suggests
- future * suggests
- testthat * suggests
- tibble * suggests
- withr * suggests
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action 4.1.4 composite
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v4 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite