Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: windows-latest, r: 'devel'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: windows-latest, r: 'devel'}
- {os: windows-latest, r: 'oldrel'}
- {os: windows-latest, r: 'release'}

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

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
run: Rscript -e 'roxygen2::roxygenise()'
- name: commit
run: |
git add man/\* NAMESPACE
git add man/\* NAMESPACE DESCRIPTION
git commit -m 'Document'
- uses: r-lib/actions/pr-push@master
with:
Expand Down
50 changes: 17 additions & 33 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,35 +1,19 @@
Package: kwb.qmra
Title: QMRA (quantitative microbial risk assessment)
Version: 0.3.0
Authors@R:
c(person(given = "Michael",
family = "Rustler",
role = c("aut", "cre"),
email = "michael.rustler@kompetenz-wasser.de",
comment = c(ORCID = "0000-0003-0647-7726")),
person(given = "Hauke",
family = "Sonnenberg",
role = "aut",
email = "hauke.sonnenberg@kompetenz-wasser.de",
comment = c(ORCID = "0000-0001-9134-2871")),
person(given = "Wolfgang",
family = "Seis",
role = c("ctb", "rev"),
email = "wolfgang.seis@kompetenz-wasser.de",
comment = c(ORCID = "0000-0002-7436-8575")),
person(given = "Ralf",
family = "Junghanns",
role = c("ctb"),
email = "ralf.junghanns@gmail.com",
comment = c(ORCID = "")),
person(given = "Kompetenzzentrum Wasser Berlin gGmbH",
role = "cph"),
person(given = "AquaNES",
role = "fnd"),
person(given = "DEMOWARE",
role = "fnd"),
person(given = "Smart-Control",
role = "fnd"))
Version: 0.3.0.9000
Authors@R: c(
person("Michael", "Rustler", , "michael.rustler@kompetenz-wasser.de", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-0647-7726")),
person("Hauke", "Sonnenberg", , "hauke.sonnenberg@kompetenz-wasser.de", role = "aut",
comment = c(ORCID = "0000-0001-9134-2871")),
person("Wolfgang", "Seis", , "wolfgang.seis@kompetenz-wasser.de", role = c("ctb", "rev"),
comment = c(ORCID = "0000-0002-7436-8575")),
person("Ralf", "Junghanns", , "ralf.junghanns@gmail.com", role = "ctb"),
person("Kompetenzzentrum Wasser Berlin gGmbH (KWB)", role = "cph"),
person("AquaNES", role = "fnd"),
person("DEMOWARE", role = "fnd"),
person("Smart-Control", role = "fnd")
)
Description: QMRA for water supply systems.
License: MIT + file LICENSE
URL: http://github.com/KWB-R/kwb.qmra/
Expand Down Expand Up @@ -66,9 +50,9 @@ Suggests:
VignetteBuilder:
knitr
Remotes:
github::kwb-r/kwb.utils@v0.7.0,
github::kwb-r/qmra.db@v0.10.0
github::kwb-r/kwb.utils,
github::kwb-r/qmra.db
Config/testthat/edition: 3
Encoding: UTF-8
LazyLoad: yes
RoxygenNote: 7.1.1
Config/testthat/edition: 3
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 - 2020 Kompetenzzentrum Wasser Berlin gGmbH (KWB)
Copyright (c) 2016 - 2022 Kompetenzzentrum Wasser Berlin gGmbH (KWB)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License

Copyright (c) 2016 - 2020 Kompetenzzentrum Wasser Berlin gGmbH (KWB)
Copyright (c) 2016 - 20220 Kompetenzzentrum Wasser Berlin gGmbH (KWB)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# [kwb.qmra 0.3.1](https://github.com/KWB-R/kwb.qmra/releases/tag/v0.3.1) <small>2022-06-08</small>

* Harmonise with kwb.pkgbuild

# [kwb.qmra 0.3.0](https://github.com/KWB-R/kwb.qmra/releases/tag/v0.3.0) <small>2021-02-23</small>

Adaptions for project [Smart-Control](https://www.kompetenz-wasser.de/en/project/smart-control/):
Expand Down
50 changes: 29 additions & 21 deletions R/random_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,52 +89,60 @@ get_percentile <- function(percent_within_minmax = 0.9)
}

#' Create random distribution
#' @param type "uniform" calls runif(), "log10_uniform" calls
#' 10^runif(number_of_events, log10_min, log10_max), "triangle" calls
#' EnvStats::rtri(), "lognorm" calls rlnorm(), "norm" calls rnorm() and
#' "log10_norm" calls 10^rnorm(number_of_events, mean = log10_mean,
#' @param type "uniform" calls \code{\link[stats]{runif}}, "log10_uniform" calls
#' 10^\code{\link[stats]{runif}}(number_of_events, log10_min, log10_max), "triangle"
#' calls \code{\link[EnvStats]{rtri}}, "lognorm" calls \code{\link[stats]{rlnorm}},
#' "norm" calls \code{\link[stats]{rnorm}} and "log10_norm" calls
#' 10^\code{\link[stats]{rnorm}}(number_of_events, mean = log10_mean,
#' sdev = log10_sdev), (default: "uniform")
#' @param number_of_repeatings how often should the random distribution with the
#' same parameters be generated (default: 1)
#' @param number_of_events number of events
#' @param value constant value (no random number), gets repeated number_of_events
#' times (if 'type' = 'value')
#' @param min minimum value (default: 10), only used if 'type' is "runif" or
#' @param min minimum value (default: 10), only used if 'type' is "uniform" or
#' "triangle"
#' @param max maximum value (default: 1000), only used if 'type' is "runif" or
#' @param max maximum value (default: 1000), only used if 'type' is "uniform" or
#' "triangle"
#' @param percent_within_minmax percent of data point within min/max (default:
#' 0.9 i.e. 90 percent
#' 0.9 i.e. 90 percent,see also \code{\link{get_percentile}}
#' @param min_zero only used if 'type' is "log10_uniform" or
#' "log10_norm", "norm" or "lognorm" and "min" value equal zero.
#' In this case the zero is replaced by this value (default: 0.01), see also
#' \code{\link{default_min}}
#' @param log10_min minimum value (default: default_min(min, max,
#' @param log10_min minimum value (default: \code{\link{default_min}}(min, max,
#' min_zero, f = log10)), only used if 'type' is "log10_uniform" or "log10_norm"
#' @param log10_max maximum value (default: ifelse(max > 0, log10(max),
#' log10_zero_threshold), only used if 'type' is "log10_uniform" or "log10_norm"
#' @param log10_max maximum value (default: \code{\link{default_max}}(max,
#' min_zero * 10, f = log10)), only used if 'type' is "log10_uniform" or "log10_norm"
#' @param log10_mean mean value (default: (log10_min + log10_max)/2), only used
#' if 'type' is "log10_norm"
#' @param log10_sdev standard deviation (default: abs((log10_max- log10_mean) /
#' get_percentile(0.95)), only used if 'type' is "log10_norm"
#' @param mean mean value (default: (default_min(min, max, min_zero) /
#' default_max(max, 10*min_zero)) / 2), only used if 'type' is "norm"
#' @param sdev standard deviation (default: abs((default_max(max, 10*min_zero) -
#' mean) / get_percentile(0.95))), only used if 'type' is "norm"
#' @param meanlog log mean value (default: mean(log((min + max) / 2))), only
#' \code{\link{get_percentile}}(percent_within_minmax))), only used if 'type' is
#' "log10_norm"
#' @param mean mean value (default: (\code{\link{default_min}}(min, max, min_zero) /
#' \code{\link{default_max}}(max, 10*min_zero)) / 2), only used if 'type' is "norm"
#' @param sdev standard deviation (default: abs((log10_max - log10_mean) /
#' \code{\link{get_percentile}}(percent_within_minmax))), only used if 'type' is
#' "norm"
#' @param meanlog log mean value (default:
#' mean(log( \code{\link{default_min}}(min, max, min_zero) +
#' \code{\link{default_max}}(max, 10 * min_zero)) / 2)), only
#' used if 'type' is "lognorm"
#' @param sdlog standard deviation (default: abs(sd(c(default_min(min, max,
#' min_zero, f = log)))) ), only used if 'type' is "lognorm"
#' @param mode (default: default_min(min, max, min_zero) +
#' default_max(max, 10 * min_zero) / 2), only used if 'type' is "triangle"
#' @param sdlog standard deviation (default: abs(sd(c(
#' \code{\link{default_min}}(min, max, min_zero, f = log),
#' \code{\link{default_max}}(max, 10 * min_zero, f = log)))),
#' only used if 'type' is "lognorm"
#' @param mode (default: \code{\link{default_min}}(min, max, min_zero) +
#' \code{\link{default_max}}(max, 10 * min_zero) / 2), only used if 'type' is
#' "triangle"
#' @param debug print debug information (default: TRUE)
#' @return list with parameters of user defined random distribution and
#' corresponding values
#' @export
#' @importFrom stats sd qnorm runif rnorm rlnorm
#' @importFrom dplyr mutate
#' @importFrom rlang .data
#' @seealso for random triangle see \code{\link{rtri}}, for default
#' @seealso for random triangle see \code{\link[EnvStats]{rtri}}, for default
#' min/max see \code{\link{default_min}}, \code{\link{default_max}} and
#' \code{\link{get_percentile}}
#'
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
[![DOI](https://zenodo.org/badge/68301647.svg)](https://zenodo.org/badge/latestdoi/68301647)
[![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/kwb-r/kwb.qmra/master?urlpath=rstudio)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/kwb.qmra)]()
[![R-Universe_Status_Badge](https://kwb-r.r-universe.dev/badges/kwb.qmra)](https://kwb-r.r-universe.dev/)

# kwb.qmra

Expand All @@ -13,6 +15,23 @@ Launch repository (from master) in cloud RStudio session:

[![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/kwb-r/kwb.qmra/master?urlpath=rstudio)

## Installation

For installing the latest release of this R package run the following code below:

```r
# Enable repository from kwb-r
options(repos = c(
kwbr = 'https://kwb-r.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))

# Download and install kwb.qmra in R
install.packages('kwb.qmra')

# Browse the kwb.qmra manual pages
help(package = 'kwb.qmra')
```

## Documentation

Development version: [https://kwb-r.github.io/kwb.qmra/dev](https://kwb-r.github.io/kwb.qmra/dev)
Expand Down
64 changes: 43 additions & 21 deletions _pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,39 @@ authors:
Michael Rustler:
href: https://mrustl.de
Hauke Sonnenberg:
href: https://github.com/hsonne
href: https://www.kompetenz-wasser.de/en/ueber-uns/team/hauke-sonnenberg
Wolfgang Seis:
href: https://www.researchgate.net/profile/Wolfgang_Seis
Kompetenzzentrum Wasser Berlin gGmbH:
href: https://www.kompetenz-wasser.de
html: <img src="http://www.kompetenz-wasser.de/wp-content/uploads/2017/08/cropped-logo-kwb_klein-new.png" height="24" />
AquaNES:
href: https://www.kompetenz-wasser.de/en/project/aquanes/
html: <img src="https://www.kompetenz-wasser.de/wp-content/uploads/2017/09/11-558x122.jpg" height="24" />
href: https://www.kompetenz-wasser.de/en/ueber-uns/team/wolfgang-seis
AquaNES:
href: https://www.kompetenz-wasser.de/en/forschung/projekte/aquanes
html: <img src='https://old.kompetenz-wasser.de/wp-content/uploads/2017/09/11-558x122.jpg' alt='Project AquaNES'
width='72' />
DEMOWARE:
href: https://www.kompetenz-wasser.de/en/project/demoware/
html: <img src="https://www.kompetenz-wasser.de/wp-content/uploads/2017/05/demoware-logo.png" height="24" />
href: https://www.kompetenz-wasser.de/en/forschung/projekte/demoware/
html: <img src='https://www.kompetenz-wasser.de/media/pages/forschung/projekte/demoware/46595105f4-1639132759/demoware-logo.png' alt='Project DEMOWARE'
width='72' />
Smart-Control:
href: https://www.kompetenz-wasser.de/en/project/smart-control/
html: <img src='https://smart-control.inowas.com/wp-content/uploads/2020/06/cropped-SMART_logo_black.png'
height='24' />
href: https://www.kompetenz-wasser.de/en/forschung/projekte/smart-control/
html: <img src='https://smart-control.inowas.com/wp-content/uploads/2020/06/cropped-SMART_logo_black.png' alt='Project Smart-Control'
width='72' />
Kompetenzzentrum Wasser Berlin gGmbH (KWB):
href: https://www.kompetenz-wasser.de
html: <img src='https://publications.kompetenz-wasser.de/img/KWB-Logo.svg' alt='KWB'
width='72' />
template:
params:
bootswatch: cerulean
docsearch:
api_key: ba545525664b60ab9e580ae0f7f4ac02
index_name: kwb_qmra
bootstrap: 5
bootswatch: cerulean
bslib:
bg: '#ffffff'
fg: '#000000'
primary: '#007aff'
border-radius: 0.5rem
btn-border-radius: 0.25rem
development:
mode: auto

navbar:
title: ~
type: default
left:
- text: Background
href: articles/general.html
Expand Down Expand Up @@ -89,6 +97,14 @@ reference:
Functions for plotting QMRA results
contents:
- starts_with("plot_")

- title: Datasets
desc: >
Datasets within R package
contents:
- config_default_json
- config_dummy_json
- risk_dummy_json

- title: Export data
desc: >
Expand All @@ -100,16 +116,22 @@ reference:
- title: Helper functions
desc: >
Helper functions for performing QMRA
contents:
contents:
- backcalc_infectionRisk_perDay
- calc_health_risk
- calc_infection_risk
- config_write_dummy
- create_random_distribution
- start_with("default")
- default_max
- default_min
- generate_random_values
- get_percentile
- distribution_repeater
- dr.betapoisson
- dr.db_download
- dr.db_model
- dr.expo
- poisson_dose
- run_app
- who_getTreatment

17 changes: 14 additions & 3 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
[![DOI](https://zenodo.org/badge/68301647.svg)](https://zenodo.org/badge/latestdoi/68301647)
[![Binder](http://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/kwb-r/kwb.qmra/master?urlpath=rstudio)

[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/kwb.qmra)]()
[![R-Universe_Status_Badge](https://kwb-r.r-universe.dev/badges/kwb.qmra)](https://kwb-r.r-universe.dev/)

An R package for QMRA (quantitative microbial risk assessment) of water supply systems


## Installation

For installing the latest release of this R package run the following code below:

```r
#install.packages("remotes", repos = "https://cloud.r-project.org")
remotes::install_github("KWB-R/kwb.qmra")
# Enable repository from kwb-r
options(repos = c(
kwbr = 'https://kwb-r.r-universe.dev',
CRAN = 'https://cloud.r-project.org'))

# Download and install kwb.qmra in R
install.packages('kwb.qmra')

# Browse the kwb.qmra manual pages
help(package = 'kwb.qmra')
```
Loading