distplyr
A grammar for manipulating probability distributions.
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
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (17.1%) to scientific vocabulary
Keywords
r
r-package
rstats
Last synced: 10 months ago
·
JSON representation
Repository
A grammar for manipulating probability distributions.
Basic Info
- Host: GitHub
- Owner: probaverse
- License: other
- Language: R
- Default Branch: main
- Homepage: https://distplyr.probaverse.com
- Size: 7.69 MB
Statistics
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
r
r-package
rstats
Created over 2 years ago
· Last pushed 11 months ago
Metadata Files
Readme
Changelog
Contributing
License
Code of conduct
Support
Codemeta
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
fig.width = 5,
fig.height = 3,
fig.align = "center"
)
```
# distplyr
[](https://www.tidyverse.org/lifecycle/#experimental)
[](https://www.repostatus.org/#wip)
[](https://codecov.io/gh/probaverse/distplyr)
[](https://CRAN.R-project.org/package=distplyr)
[](https://cran.r-project.org/web/licenses/MIT)
[](https://github.com/probaverse/distplyr/actions/workflows/R-CMD-check.yaml)
distplyr breathes life into probability distributions by providing a grammar for their modification and reshaping. It works seamlessly with distribution objects from the [distionary](https://distionary.probaverses.com) package.
The distplyr package name is inspired by the [dplyr](https://dplyr.tidyverse.org/) R package: whereas distplyr provides a grammar for manipulating _distributions_, dplyr provides a grammar for manipulating _data_.
## Installation
`distplyr` is not on CRAN yet, so the best way to install it is:
``` r
remotes::install_github("probaverse/distplyr")
```
## Basic Usage
```{r, warning = FALSE, message = FALSE}
library(distplyr)
```
Want to model a count variable that starts at 1, not 0? Consider shifting a Poisson distribution.
```{r}
(d1 <- dst_pois(1.5) + 1)
```
Here's its probability mass function:
```{r}
enframe_pmf(d1, at = 0:10) |>
plot()
```
Or, maybe you have positive continuous data and you'd like its tail to continue as an exponential distribution:
```{r}
x <- c(1.6, 0.9, 0.2, 1.4, 0.4, 0.3, 0.2, 0.4, 0.2, 1.5)
mu <- mean(x)
(d2 <- dst_empirical(x) |>
graft_right(dst_exp(mu), breakpoint = max(x)))
```
Here's the survival function:
```{r}
plot(d2, "survival", from = 0, to = 5, n = 1000)
```
Or maybe you'd like to mix the empirical and Exponential distributions:
```{r}
(d4 <- mix(dst_empirical(x), dst_exp(mu)))
plot(d4, "survival", from = 0, to = 5, n = 1000)
```
## distplyr in Context
There are a few other R packages that handle probability distributions. The key differentiator with distplyr is its grammar, and the flexibility of the package distionary, which distplyr sits on top of.
Some examples:
- The distributional package also allows for distribution manipulation, but is less flexible, and builds vectorization into the package. distplyr (and distionary) deliberately leaves vectorization up to the user, since distributions can be evaluated to produce a variety of output types.
- Development of distributional appears to have happened at the same time as distplyr, and distributional uses a similar family of functions -- `dist_*()` -- to make probability distributions.
- The [distr](https://cran.r-project.org/web/packages/distr/index.html) package allows you to make distributions including empirical ones, and transform them, using S4 classes, but the interface is complex. distplyr aims to provide a human-centric interface by providing a grammar.
## Acknowledgements
The creation of distplyr would not have been possible without the support of the R Consortium, The Natural Science and Engineering Research Council of Canada (NSERC), The University of British Columbia, and BGC Engineering Inc.
## Code of Conduct
Please note that the distplyr project is released with a [Contributor Code of Conduct](https://distplyr.probaverse.com/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.
Owner
- Name: probaverse
- Login: probaverse
- Kind: organization
- Repositories: 1
- Profile: https://github.com/probaverse
CodeMeta (codemeta.json)
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"identifier": "distplyr",
"description": "Provides an interface for manipulating univariate probability distributions, using verbs such as `graft`, `slice`, `mix`, `shift`, and others.",
"name": "distplyr: Manipulation of Univariate Distributions",
"codeRepository": "https://github.com/probaverse/distplyr",
"license": "https://spdx.org/licenses/MIT",
"version": "0.1.5",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.4.2 (2024-10-31)",
"author": [
{
"@type": "Person",
"givenName": "Vincenzo",
"familyName": "Coia",
"email": "vincenzo.coia@stat.ubc.ca"
},
{
"@type": "Person",
"givenName": "Amogh",
"familyName": "Joshi"
},
{
"@type": "Person",
"givenName": "Shuyi",
"familyName": "Tan"
},
{
"@type": "Person",
"givenName": "Zhipeng",
"familyName": "Zhu"
}
],
"maintainer": [
{
"@type": "Person",
"givenName": "Vincenzo",
"familyName": "Coia",
"email": "vincenzo.coia@stat.ubc.ca"
}
],
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "covr",
"name": "covr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=covr"
},
{
"@type": "SoftwareApplication",
"identifier": "knitr",
"name": "knitr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=knitr"
},
{
"@type": "SoftwareApplication",
"identifier": "rmarkdown",
"name": "rmarkdown",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rmarkdown"
},
{
"@type": "SoftwareApplication",
"identifier": "testthat",
"name": "testthat",
"version": ">= 3.0.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=testthat"
},
{
"@type": "SoftwareApplication",
"identifier": "tibble",
"name": "tibble",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=tibble"
}
],
"softwareRequirements": {
"1": {
"@type": "SoftwareApplication",
"identifier": "distionary",
"name": "distionary"
},
"2": {
"@type": "SoftwareApplication",
"identifier": "ellipsis",
"name": "ellipsis",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=ellipsis"
},
"3": {
"@type": "SoftwareApplication",
"identifier": "magrittr",
"name": "magrittr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=magrittr"
},
"4": {
"@type": "SoftwareApplication",
"identifier": "rlang",
"name": "rlang",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=rlang"
},
"5": {
"@type": "SoftwareApplication",
"identifier": "vctrs",
"name": "vctrs",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=vctrs"
},
"6": {
"@type": "SoftwareApplication",
"identifier": "stats",
"name": "stats"
},
"7": {
"@type": "SoftwareApplication",
"identifier": "purrr",
"name": "purrr",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=purrr"
},
"SystemRequirements": null
},
"fileSize": "1246.599KB",
"relatedLink": "https://distplyr.probaverse.com/",
"releaseNotes": "https://github.com/probaverse/distplyr/blob/master/NEWS.md",
"readme": "https://github.com/probaverse/distplyr/blob/main/README.md",
"contIntegration": [
"https://github.com/probaverse/distplyr/actions",
"https://codecov.io/gh/probaverse/distplyr?branch=master",
"https://github.com/probaverse/distplyr/actions/workflows/R-CMD-check.yaml"
],
"developmentStatus": "https://www.tidyverse.org/lifecycle/#experimental",
"keywords": [
"r",
"r-package",
"rstats"
]
}
GitHub Events
Total
- Watch event: 1
- Push event: 24
- Create event: 1
Last Year
- Watch event: 1
- Push event: 24
- Create event: 1
Dependencies
.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
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action v4.5.0 composite
- actions/checkout v4 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/pr-commands.yaml
actions
- actions/checkout v4 composite
- r-lib/actions/pr-fetch v2 composite
- r-lib/actions/pr-push 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 v4 composite
- actions/upload-artifact v4 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION
cran
- distionary * depends
- ellipsis * imports
- magrittr * imports
- purrr * imports
- rlang * imports
- stats * imports
- vctrs * imports
- covr * suggests
- knitr * suggests
- rmarkdown * suggests
- testthat >= 3.0.0 suggests
- tibble * suggests