Skip to content

Commit

Permalink
Merge pull request #276 from alan-turing-institute/fix_rcmdcheck
Browse files Browse the repository at this point in the history
Update rcmdcheck.yml
  • Loading branch information
RaphaelS1 authored Jun 18, 2022
2 parents 0aa2a6f + afb3fbd commit a2d0a18
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 66 deletions.
22 changes: 2 additions & 20 deletions .github/workflows/rcmdcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ jobs:
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel'}
- {os: ubuntu-20.04, r: 'release'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
Expand Down Expand Up @@ -102,20 +101,3 @@ jobs:
install.packages('covr')
covr::codecov()
shell: Rscript {0}

- name: Render rmd
if: ${{ github.event_name == 'pull_request' && runner.os == 'Linux' && matrix.config.r == 'release'}}
run: |
pak::local_install()
pak::pkg_install("rmarkdown")
rmarkdown::render('README.Rmd')
shell: Rscript {0}

- name: Commit changes
if: ${{ github.event_name == 'pull_request' && runner.os == 'Linux' && matrix.config.r == 'release'}}
uses: EndBug/add-and-commit@v7
with:
author_name: github-actions
author_email: 41898282+github-actions[bot]@users.noreply.github.com
message: 'Update README.md'
add: 'README.md'
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: distr6
Title: The Complete R6 Probability Distributions Interface
Version: 1.6.10
Version: 1.6.11
Authors@R:
c(person(given = "Raphael",
family = "Sonabend",
Expand Down
30 changes: 22 additions & 8 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,44 @@ set.seed(42)

<img src="man/figures/logo.png" align="right" alt="" width="120" />

[![CRAN Status Badge](https://www.r-pkg.org/badges/version-ago/distr6)](https://cran.r-project.org/package=distr6)
[![CRAN Checks](https://cranchecks.info/badges/worst/distr6)](https://cran.r-project.org/web/checks/check_results_distr6.html)
[![distr6 status badge](https://raphaels1.r-universe.dev/badges/distr6)](https://raphaels1.r-universe.dev)
[![tic](https://github.com/alan-turing-institute/distr6/workflows/tic/badge.svg)](https://github.com/alan-turing-institute/distr6/actions)


[![Repo Status](https://www.repostatus.org/badges/latest/active.svg)](https://github.com/alan-turing-institute/distr6)
[![Lifecycle](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://alan-turing-institute.github.io/distr6/articles/webs/api_lifecycle.html)

[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/distr6)](https://cran.r-project.org/package=distr6)
[![codecov](https://app.codecov.io/gh/alan-turing-institute/distr6/branch/master/graph/badge.svg)](https://app.codecov.io/gh/alan-turing-institute/distr6)
[![dependencies](https://tinyverse.netlify.com/badge/distr6)](https://CRAN.R-project.org/package=distr6)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

[![arXiv](https://img.shields.io/badge/arXiv-2009.02993-brightgreen.svg)](https://arxiv.org/abs/2009.02993)
[![DOI](https://zenodo.org/badge/177962537.svg)](https://zenodo.org/badge/latestdoi/177962537)
[![Gitter chat](https://badges.gitter.im/xoopR/distr6.png)](https://gitter.im/xoopR/distr6)

[![Article](https://img.shields.io/badge/Article-10.32614/RJ-2021-055-brightgreen)]([[https://doi.org/10.1093/bioinformatics/btab039](https://journal.r-project.org/archive/2021/RJ-2021-055/index.html)](https://journal.r-project.org/archive/2021/RJ-2021-055/index.html))
[![Software DOI](https://zenodo.org/badge/177962537.svg)](https://zenodo.org/badge/latestdoi/177962537)

## What is distr6?

distr6 is a unified and clean interface to organise the probability distributions implemented in R into one R6 object oriented package, as well as adding distributions yet to implemented in R, currently we have 42 probability distributions as well as 11 kernels. Building the package from the ground up and making use of tried and tested design patterns (as per Gamma et al. 1994), distr6 aims to make probability distributions easy to use, understand and analyse.

distr6 extends the work of Peter Ruckdeschel, Matthias Kohl et al. who created the first object-oriented (OO) interface for distributions using S4. Their [distr package](http://distr.r-forge.r-project.org/) is currently the gold-standard in R for OO distribution handling. Using R6 we aim to take this even further and to create a scalable interface that can continue to grow with the community. Full details of the API and class structure can be seen in the [distr6 website](https://alan-turing-institute.github.io/distr6/).

## Citation

If you use distr6 in your research please cite as

```
@article{RJ-2021-055,
author = {Raphael Sonabend and Franz J. Király},
title = {{distr6: R6 Object-Oriented Probability Distributions
Interface in R}},
year = {2021},
journal = {{The R Journal}},
doi = {10.32614/RJ-2021-055},
url = {https://doi.org/10.32614/RJ-2021-055},
pages = {444--466},
volume = {13},
number = {1}
}
```

## Main Features

distr6 is not intended to replace the base R distributions function but instead to give an alternative that focuses on distributions as objects that can be manipulated and accessed as required. The main features therefore centre on OOP practices, design patterns and API design. Of particular note:
Expand Down
77 changes: 40 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Status](https://www.repostatus.org/badges/latest/active.svg)](https://github.com

[![CRAN
Downloads](https://cranlogs.r-pkg.org/badges/grand-total/distr6)](https://cran.r-project.org/package=distr6)
[![codecov](https://app.codecov.io/gh/alan-turing-institute/distr6/branch/master/graph/badge.svg)](https://app.codecov.io/gh/alan-turing-institute/distr6))
[![codecov](https://app.codecov.io/gh/alan-turing-institute/distr6/branch/master/graph/badge.svg)](https://app.codecov.io/gh/alan-turing-institute/distr6)
[![dependencies](https://tinyverse.netlify.com/badge/distr6)](https://CRAN.R-project.org/package=distr6)
[![License:
MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Expand Down Expand Up @@ -66,36 +66,42 @@ B$kurtosis()
B$rand(5)
#> [1] 7 7 4 7 6
summary(B)
#> Binomial Probability Distribution. Parameterised with:
#> prob = 0.5, qprob = 0.5, size = 10
#>
#> Quick Statistics
#> Binomial Probability Distribution.
#> Parameterised with:
#>
#> Id Support Value Tags
#> 1: prob [0,1] 0.5 linked,required
#> 2: qprob [0,1] linked,required
#> 3: size ℕ+ 10 required
#>
#>
#> Quick Statistics
#> Mean: 5
#> Variance: 2.5
#> Skewness: 0
#> Ex. Kurtosis: -0.2
#>
#> Support: {0, 1,...,9, 10} Scientific Type: ℕ0
#>
#> Traits: discrete; univariate
#> Properties: symmetric; platykurtic; no skew
#>
#> Support: {0, 1,...,9, 10} Scientific Type: ℕ0
#>
#> Traits: discrete; univariate
#> Properties: symmetric; platykurtic; no skew
```

Flexible construction of distributions for common parameterisations

``` r
Exponential$new(rate = 2)
#> Exp(rate = 2, scale = 0.5)
#> Exp(rate = 2)
Exponential$new(scale = 2)
#> Exp(rate = 0.5, scale = 2)
#> Exp(scale = 2)
Normal$new(mean = 0, prec = 2)
#> Norm(mean = 0, var = 0.5, sd = 0.707106781186548, prec = 2)
#> Norm(mean = 0, prec = 2)
Normal$new(mean = 0, sd = 3)$parameters()
#> id value support description
#> 1: mean 0 Mean - Location Parameter
#> 2: var 9 ℝ+ Variance - Squared Scale Parameter
#> 3: sd 3 ℝ+ Standard Deviation - Scale Parameter
#> 4: prec 0.1111111 ℝ+ Precision - Inverse Squared Scale Parameter
#> Id Support Value Tags
#> 1: mean ℝ 0 required
#> 2: prec ℝ+ linked,required
#> 3: sd ℝ+ 3 linked,required
#> 4: var ℝ+ linked,required
```

Decorators for extending functionality of distributions to more complex
Expand All @@ -105,37 +111,24 @@ modelling methods
B <- Binomial$new()
decorate(B, "ExoticStatistics")
#> Binomial is now decorated with ExoticStatistics
#> Binom(prob = 0.5, qprob = 0.5, size = 10)
#> Binom(prob = 0.5, size = 10)
B$survival(2)
#> [1] 0.9453125
decorate(B, "CoreStatistics")
#> Binomial is now decorated with CoreStatistics
#> Binom(prob = 0.5, qprob = 0.5, size = 10)
#> Binom(prob = 0.5, size = 10)
B$kthmoment(6)
#> Results from numeric calculations are approximate only. Better results may be available.
#> [1] 190
```

S3 compatibility to make the interface more flexible for users who are
less familiar with OOP

``` r
B <- Binomial$new()
mean(B) # B$mean()
#> [1] 5
variance(B) # B$variance()
#> [1] 2.5
cdf(B, 2:5) # B$cdf(2:5)
#> [1] 0.0546875 0.1718750 0.3769531 0.6230469
```

Wrappers including truncation, huberization and product distributions
for manipulation and composition of distributions.

``` r
B <- Binomial$new()
TruncatedDistribution$new(B, lower = 2, upper = 5) #Or: truncate(B,2,5)
#> TruncBinom(Binom__prob = 0.5, Binom__qprob = 0.5,...,trunc__lower = 2, trunc__upper = 5)
#> TruncBinom(Binom__prob = 0.5, Binom__size = 10, trunc__lower = 2, trunc__upper = 5)
N <- Normal$new()
MixtureDistribution$new(list(B,N), weights = c(0.1, 0.9))
#> Binom wX Norm
Expand Down Expand Up @@ -172,18 +165,28 @@ distr6 has three primary use-cases:

## Installation

For the latest release on CRAN, install with
distr6 can be installed from
[R-Universe](https://raphaels1.r-universe.dev/ui#package:distr6)

``` r
install.packages("distr6")
# Enable repository from raphaels1
options(repos = c(
raphaels1 = 'https://raphaels1.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))
# Download and install distr6 in R
install.packages('distr6')
```

Otherwise for the latest stable build
And GitHub

``` r
remotes::install_github("alan-turing-institute/distr6")
```

distr6 [will not be on
CRAN](https://twitter.com/RaphaelS101/status/1506321623250571265) for
the forseeable future.

## Future Plans

Our plans for the next update include
Expand Down

0 comments on commit a2d0a18

Please sign in to comment.