https://github.com/mkearney/dapr
βπΌππΌππΌππΌ Dependency-free purrr-like apply/map/iterate functions
Science Score: 33.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
βCITATION.cff file
-
βcodemeta.json file
-
β.zenodo.json file
-
βDOI references
Found 3 DOI reference(s) in README -
βAcademic publication links
Links to: zenodo.org -
βCommitters with academic emails
1 of 1 committers (100.0%) from academic institutions -
βInstitutional organization owner
-
βJOSS paper metadata
-
βScientific vocabulary similarity
Low similarity (19.7%) to scientific vocabulary
Keywords
for-loops
functional-programming
iterator
r
r-package
rstats
Last synced: 6 months ago
·
JSON representation
Repository
βπΌππΌππΌππΌ Dependency-free purrr-like apply/map/iterate functions
Basic Info
- Host: GitHub
- Owner: mkearney
- License: gpl-3.0
- Language: R
- Default Branch: master
- Homepage: https://dapr.mikewk.com
- Size: 998 KB
Statistics
- Stars: 52
- Watchers: 3
- Forks: 0
- Open Issues: 1
- Releases: 0
Topics
for-loops
functional-programming
iterator
r
r-package
rstats
Created over 7 years ago
· Last pushed over 6 years ago
Metadata Files
Readme
License
README.Rmd
---
output: github_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE, collapse = TRUE, comment = "#>")
library(dapr)
```
# dapr
[](https://travis-ci.org/mkearney/dapr)
[](https://cran.r-project.org/package=dapr)
[](https://codecov.io/gh/mkearney/dapr?branch=master)
[](https://doi.org/10.5281/zenodo.2528504)


[](https://www.tidyverse.org/lifecycle/#experimental)
Dependency-free purrr-like apply/map/iterate functions
## Installation
Install the development version from Github with:
``` r
## install remotes pkg if not already
if (!requireNamespace("remotes", quietly = TRUE)) {
install.packages("remotes")
}
## install from github
remotes::install_github("mkearney/dapr")
```
## {dapr} vs. {base} & {purrr}?
**{dapr}** provides the ease and consistency of [**{purrr}**](https://purrr.tidyverse.org),
(see also: simple benchmark results plot below) including use of `~` and `.x`,
without all the dependencies. In other words, use **{dapr}** when you want a
purrr-like experience but you need a lightweight solution.
## Use
Function names use the convention `*ap()` where **`*`** is the first letter of output data type.
+ vap for **vectors**
+ lap for **lists**
+ dap for **data frames**
Common inputs:
+ `.data` Input objectβnumeric, character, list, data frame, etc.βover which elements will be iterated. If matrix or data frame, each column will be treated as the elements which are to be iterated over.
+ `.f` Function to apply to each element of input object. This can be written as a single function name e.g., `mean`, a formula-like function call where `.x` is assumed to be the iterated over element of input data e.g., `~ mean(.x)`, or an in-line function definition e.g., `function(x) mean(x)`.
### Vectors
Functions that apply expressions to input data objects and return atomic vectors
e.g., numeric (double), character, logical.
+ **`vap_dbl()`** Iterate and return **numeric** vector.
+ **`vap_int()`** Iterate and return **integer** vector.
+ **`vap_lgl()`** Iterate and return **logical** vector.
+ **`vap_chr()`** Iterate and return **character** vector.
```{r}
## create data
set.seed(2018)
d <- replicate(5, rnorm(10), simplify = FALSE)
e <- replicate(5, sample(letters, 10), simplify = FALSE)
## numeric
vap_dbl(d, ~ mean(.x))
## integer
vap_int(d, length)
## logical
vap_lgl(d, ~ max(.x) > 3)
## character
vap_chr(e, paste, collapse = "")
```
### Lists
Function(s) that apply expressions to input data objects and return lists.
+ **`lap()`** Iterate and return a **list** vector.
```{r}
## list of strings
lap(e[1:2], ~ paste0(.x, "."))
```
+ **`ilap()`** Iterate over sequence length `.i` (instead of `.x`) and return a **list** vector.
```{r}
## list of strings
ilap(1:4, ~ paste0(letters[.i], rev(LETTERS)[.i]))
```
### Data frames
Functions that apply expressions to input data objects and return data frames.
+ **`dap*()`** Iterate and return a **data frame**
- **`dapc()`** Iterate over **columns**
- **`dapr()`** Iterate over **rows**
+ **`dap*_if()`** Conditionally iterate
- **`dapc_if()`** Conditionally iterate over **columns**
- **`dapr_if()`** Conditionally iterate over **rows**
```{r}
## some data
d <- data.frame(
a = letters[1:3],
b = rnorm(3),
c = rnorm(3),
stringsAsFactors = FALSE
)
## column explicit (same as dap)
dapc(d[-1], ~ round(.x, 2))
## rows
dapr(d[-1], round, 3)
## conditional COLUMNS
dapc_if(d, is.numeric, ~ round(.x, 4))
## conditional ROWS
dapr_if(d[-1], ~ sum(.x) >= -.7, ~ round(.x, 0))
```
Owner
- Name: Michael W. Kearney
- Login: mkearney
- Kind: user
- Location: United States
- Company: @AwareHQ
- Website: https://mikewk.com/
- Twitter: kearneymw
- Repositories: 16
- Profile: https://github.com/mkearney
ππ§βπ»π Senior Data Scientist
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: almost 3 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Michael W. Kearney | k****w@m****u | 52 |
Committer Domains (Top 20 + Academic)
missouri.edu: 1
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 1
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- ccshao (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
DESCRIPTION
cran
- covr * suggests
- testthat >= 2.1.0 suggests