Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mps9506/tbrf
time-based rolling functions in R
https://github.com/mps9506/tbrf
r
Last synced: 28 days ago
JSON representation
time-based rolling functions in R
- Host: GitHub
- URL: https://github.com/mps9506/tbrf
- Owner: mps9506
- License: other
- Created: 2018-07-18T22:55:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-13T21:55:38.000Z (over 2 years ago)
- Last Synced: 2024-10-13T14:28:19.036Z (2 months ago)
- Topics: r
- Language: R
- Homepage: https://mps9506.github.io/tbrf/
- Size: 3.87 MB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- jimsghstars - mps9506/tbrf - time-based rolling functions in R (R)
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "##",
fig.path = "man/figures/README-",
fig.retina = 2
)
```# tbrf
[![lifecycle](https://img.shields.io/badge/lifecycle-retired-orange.svg)](https://www.tidyverse.org/lifecycle/#retired)
[![CRAN version](https://www.r-pkg.org/badges/version/tbrf)](https://CRAN.R-project.org/package=tbrf)
[![R build status](https://github.com/mps9506/tbrf/workflows/R-CMD-check/badge.svg)](https://github.com/mps9506/tbrf/actions)
[![Coverage status](https://codecov.io/gh/mps9506/tbrf/branch/master/graph/badge.svg)](https://codecov.io/github/mps9506/tbrf?branch=master)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)tbrf is retired. I will maintain the package to ensure it remains on CRAN but do not expect additional functionality or improvements. I highly recommend [runner](https://gogonzo.github.io/runner/) for the same functionality but faster!
The goal of tbrf is to provide time-window based rolling statistical functions. The package differs from other rolling statistic packages because the intended use is for irregular measured data. Although tbrf can be used to apply statistical functions to regularly sampled data, [`zoo`](https://CRAN.R-project.org/package=zoo), [`RcppRoll`](https://cran.r-project.org/package=RcppRoll), and other packages provide fast, efficient, and rich implementations of rolling/windowed functions.
An appropriate example case is water quality data that is measured at irregular time intervals. Regulatory compliance is often based on a statistical average measure or exceedance probability applied to all samples collected in the previous 7-years. tbrf can be used to display regulatory status at any sample point.
tbrf identifies the previous n measurements within the specified time window, applies the function, and outputs a variable with the result of the rolling statistical measure.
## Installation
tbrf is available on CRAN:
```{r eval=FALSE}
install.packages("tbrf")
```The development version is maintained on github and can be installed as:
```{r eval=FALSE}
install.packages(remotes)
remotes::install_github("mps9506/tbrf")
```## Available Functions
- `tbr_binom`: Rolling binomial probability with confidence intervals.
- `tbr_gmean`: Rolling geometric mean with confidence intervals.
- `tbr_mean`: Rolling mean with confidence intervals.
- `tbr_median`: Rolling median with confidence intervals.
- `tbr_misc`: Accepts user specified function.
- `tbr_sd`: Rolling standard deviation.
- `tbr_sum`: Rolling sum.
## Usage
See:
https://mps9506.github.io/tbrf/
## Example
Plot a rolling 1-hour mean:
```{r tbr_hour, fig.retina=2, message=FALSE, warning=FALSE}
library(tbrf)
library(dplyr)
library(ggplot2)
library(ggalt)y = 3 * sin(2 * seq(from = 0, to = 4*pi, length.out = 100)) + rnorm(100)
time = sample(seq(as.POSIXct(strptime("2017-01-01 00:01:00", "%Y-%m-%d %H:%M:%S")),
as.POSIXct(strptime("2017-01-01 23:00:00", "%Y-%m-%d %H:%M:%S")),
by = "min"), 100)df <- tibble(y, time)
df %>%
tbr_mean(y, time, "hours", n = 1) %>%
ggplot() +
geom_point(aes(time, y)) +
geom_step(aes(time, mean))
```Plot a rolling 3-hour mean:
```{r tbr_threehour, fig.retina=2, message=FALSE, warning=FALSE}
df %>%
tbr_mean(y, time, "hours", n = 3) %>%
ggplot() +
geom_point(aes(time, y)) +
geom_step(aes(time, mean))
```## Contributing
Please note that this project is released with a [Contributor Code of Conduct](https://github.com/mps9506/tbrf/blob/master/CODE_OF_CONDUCT.md).
By participating in this project you agree to abide by its terms.## License
tbrf code is released under GPL-3 | LICENSE.md
`binom_ci()` is an implementation of code licensed under GPL (>=2) by Frank Harrell's [`Hmisc`](https://github.com/harrelfe/Hmisc) package.
If you can cite the use of this software, please use `citation("tbrf")`
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3727319.svg)](https://doi.org/10.5281/zenodo.3727319.)## Test Results
```{r message=FALSE, warning=FALSE, error=FALSE}
library(tbrf)date()
devtools::test()
```