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
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.1%) to scientific vocabulary
Last synced: 9 months ago
·
JSON representation
Repository
:runner: R package performing simple running calculations
Basic Info
- Host: GitHub
- Owner: gogonzo
- Language: R
- Default Branch: main
- Homepage: https://gogonzo.github.io/runner/
- Size: 3.42 MB
Statistics
- Stars: 52
- Watchers: 3
- Forks: 4
- Open Issues: 6
- Releases: 12
Created over 8 years ago
· Last pushed about 2 years ago
Metadata Files
Readme
Changelog
Codemeta
README.Rmd
---
output: rmarkdown::github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# `runner` an R package for running operations.
#
[](https://github.com/gogonzo/runner/actions)
[](https://CRAN.R-project.org/package=runner)
[](https://cran.r-project.org/package=runner)
## About
Package contains standard running functions (aka. rolling) with additional
options like varying window size, lagging, handling missings and windows
depending on date. `runner` brings also rolling streak and rolling which, what
extends beyond range of functions already implemented in R packages. This
package can be successfully used to manipulate and aggregate time series or
longitudinal data.
## Installation
Install package from from GitHub or from CRAN.
```{r gh-installation, eval=FALSE}
# devtools::install_github("gogonzo/runner")
install.packages("runner")
```
## Using runner
`runner` package provides functions applied on running windows. The most
universal function is `runner::runner` which gives user possibility to apply
any R function `f` in running window. In example below 4-months correlation
is calculated lagged by
1 month.
```{r eval=FALSE}
library(runner)
x <- data.frame(
date = seq.Date(Sys.Date(), Sys.Date() + 365, length.out = 20),
a = rnorm(20),
b = rnorm(20)
)
runner(
x,
lag = "1 months",
k = "4 months",
idx = x$date,
f = function(x) {
cor(x$a, x$b)
}
)
```
There are different kinds of running windows and all of them are implemented in
`runner`.
## Running windows
Following diagram illustrates what running windows are - in this case running
windows of length `k = 4`. For each of 15 elements of a vector each window
contains current 4 elements.

### Window size
`k` denotes number of elements in window. If `k` is a single value then window
size is constant for all elements of x. For varying window size one should specify
`k` as integer vector of `length(k) == length(x)` where each element of `k`
defines window length. If `k` is empty it means that window will be cumulative
(like `base::cumsum`). Example below illustrates window of `k = 4` for 10th
element of vector `x`.

```{r eval=FALSE}
runner(1:15, k = 4)
```
### Window lag
`lag` denotes how many observations windows will be lagged by. If `lag` is a
single value than it is constant for all elements of x. For varying lag size one
should specify `lag` as integer vector of `length(lag) == length(x)` where each
element of `lag` defines lag of window. Default value of `lag = 0`. Example
below illustrates window of `k = 4` lagged by `lag = 2` for 10-th element of
vector `x`. Lag can also be negative value, which shifts window forward instead
of backward.

```{r eval=FALSE}
runner(
1:15,
k = 4,
lag = 2
)
```
### Windows depending on date
Sometimes data points in dataset are not equally spaced (missing weekends,
holidays, other missings) and thus window size should vary to keep expected time
frame. If one specifies `idx` argument, than running functions are applied on
windows depending on date. `idx` should be the same length as `x` of class `Date`
or `integer`. Including `idx` can be combined with varying window size, than k
will denote number of periods in window different for each data point. Example
below illustrates window of size `k = 5` lagged by `lag = 2`. In parentheses
ranges for each window.

```{r eval=FALSE}
idx <- Sys.Date() + c(4, 6, 7, 13, 17, 18, 18, 21, 27, 31, 37, 42, 44, 47, 48)
runner(
x = 1:15,
k = "5 days",
lag = "1 days",
idx = idx
)
```
### Running at
Runner by default returns vector of the same size as `x` unless one puts any-size
vector to `at` argument. Each element of `at` is an index on which runner
calculates function. Below illustrates output of runner for `at = c(18, 27, 45, 31)`
which gives windows in ranges enclosed in square brackets. Range for `at = 27` is
`[22, 26]` which is not available in current indices.

```{r eval=FALSE}
idx <- c(4, 6, 7, 13, 17, 18, 18, 21, 27, 31, 37, 42, 44, 47, 48)
runner(
x = idx,
k = 5,
lag = 1,
idx = idx,
at = c(18, 27, 48, 31)
)
```
### `NA` padding
Using `runner` one can also specify `na_pad = TRUE` which would return `NA` for
any window which is partially out of range - meaning that there is no sufficient
number of observations to fill the window. By default `na_pad = FALSE`, which
means that incomplete windows are calculated anyway. `na_pad` is applied on
normal cumulative windows and on windows depending on date. In example below two
windows exceed range given by `idx` so for these windows are empty for
`na_pad = TRUE`. If used sets `na_pad = FALSE` first window will be empty
(no single element within `[-2, 3]`) and last window will return elements within
matching `idx`.

```{r eval=FALSE}
idx <- c(4, 6, 7, 13, 17, 18, 18, 21, 27, 31, 37, 42, 44, 47, 48)
runner(
x = idx,
k = 5,
lag = 1,
idx = idx,
at = c(4, 18, 48, 51),
na_pad = TRUE
)
```
### Using runner with `data.frame`
User can also put `data.frame` into `x` argument and apply functions which involve
multiple columns. In example below we calculate beta parameter of `lm` model on
1, 2, ..., n observations respectively. On the plot one can observe how `lm`
parameter adapt with increasing number of observation.
```{r eval=FALSE}
date <- Sys.Date() + cumsum(sample(1:3, 40, replace = TRUE)) # unequaly spaced time series
x <- cumsum(rnorm(40))
y <- 30 * x + rnorm(40)
df <- data.frame(date, y, x)
slope <- runner(
df,
k = 10,
idx = "date",
function(x) {
coefficients(lm(y ~ x, data = x))[2]
}
)
plot(slope)
abline(h = 30, col = "blue")
```
### Parallel computation
The `runner` function can also compute windows in parallel mode. The function
doesn't initialize the parallel cluster automatically but one have to
do this outside and pass it to the `runner` through `cl` argument.
```{r eval=FALSE}
library(parallel)
#
numCores <- detectCores()
cl <- makeForkCluster(numCores)
runner(
x = df,
k = 10,
idx = "date",
f = function(x) sum(x$x),
cl = cl
)
stopCluster(cl)
```
### Build-in functions
With `runner` one can use any R functions, but some of them are optimized for
speed reasons.
These functions are:
- aggregating functions - `length_run`, `min_run`, `max_run`, `minmax_run`,
`sum_run`, `mean_run`, `streak_run`
- utility functions - `fill_run`, `lag_run`, `which_run`
Owner
- Name: Dawid Kałędkowski
- Login: gogonzo
- Kind: user
- Location: Malmö/Sweden
- Repositories: 4
- Profile: https://github.com/gogonzo
> data_scientist -street_artist && "nba_fan"
CodeMeta (codemeta.json)
{
"@context": [
"https://doi.org/10.5063/schema/codemeta-2.0",
"http://schema.org"
],
"@type": "SoftwareSourceCode",
"identifier": "runner",
"description": "Lightweight library for rolling windows operations. Package enables\n full control over the window length, window lag and a time indices. With a runner \n one can apply any R function on a rolling windows. The package eases work with \n equally and unequally spaced time series.",
"name": "runner: Running Operations for Vectors",
"issueTracker": "https://github.com/gogonzo/runner/issues",
"license": "https://spdx.org/licenses/GPL-2.0",
"version": "0.4.0",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.0.5 (2021-03-31)",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"author": [
{
"@type": "Person",
"givenName": "Dawid",
"familyName": "Ka<U+0142><U+0119>dkowski",
"email": "dawid.kaledkowski@gmail.com",
"@id": "https://orcid.org/0000-0001-9533-457X"
}
],
"contributor": {},
"copyrightHolder": {},
"funder": {},
"maintainer": [
{
"@type": "Person",
"givenName": "Dawid",
"familyName": "Ka<U+0142><U+0119>dkowski",
"email": "dawid.kaledkowski@gmail.com",
"@id": "https://orcid.org/0000-0001-9533-457X"
}
],
"softwareSuggestions": [
{
"@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": "tinytest",
"name": "tinytest",
"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=tinytest"
}
],
"softwareRequirements": [
{
"@type": "SoftwareApplication",
"identifier": "R",
"name": "R",
"version": ">= 3.0"
},
{
"@type": "SoftwareApplication",
"identifier": "methods",
"name": "methods"
},
{
"@type": "SoftwareApplication",
"identifier": "parallel",
"name": "parallel"
},
{
"@type": "SoftwareApplication",
"identifier": "Rcpp",
"name": "Rcpp",
"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=Rcpp"
}
],
"codeRepository": "https://github.com/gogonzo/runner",
"releaseNotes": "https://github.com/gogonzo/runner/blob/main/NEWS.md",
"readme": "https://github.com/gogonzo/runner/blob/main/README.md",
"fileSize": "0KB",
"contIntegration": [
"https://ci.appveyor.com/project/gogonzo/runner",
"https://codecov.io/gh/gogonzo/runner/branch/main"
]
}
GitHub Events
Total
- Watch event: 1
- Issue comment event: 2
- Fork event: 2
Last Year
- Watch event: 1
- Issue comment event: 2
- Fork event: 2
Committers
Last synced: over 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Dawid Kałędkowski | d****i@v****u | 111 |
| Go Gonzo | d****i@g****m | 71 |
| Dawid Kałędkowski | g****o@g****l | 13 |
| Dawid Kałędkowski | 6****o | 5 |
| gonzo | g****o@M****l | 3 |
| Maciej Nasinski | n****j@g****m | 1 |
Committer Domains (Top 20 + Academic)
vemma.eu: 1
Issues and Pull Requests
Last synced: over 2 years ago
All Time
- Total issues: 39
- Total pull requests: 56
- Average time to close issues: about 1 month
- Average time to close pull requests: 10 days
- Total issue authors: 14
- Total pull request authors: 2
- Average comments per issue: 1.33
- Average comments per pull request: 0.05
- Merged pull requests: 51
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 4
- Average time to close issues: N/A
- Average time to close pull requests: 1 day
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 1.0
- Average comments per pull request: 0.0
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- gogonzo (19)
- MislavSag (5)
- Steviey (5)
- hedgeye-mbarr (1)
- jangorecki (1)
- JacopoVanoli (1)
- Raoul-Kima (1)
- gonzalezsieira (1)
- dchiu911 (1)
- tjohnson250 (1)
- athammad (1)
- stratodash (1)
- Aylon1 (1)
- mytarmail (1)
- euf (1)
Pull Request Authors
- gogonzo (56)
- Polkas (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 1,353 last-month
- Total docker downloads: 20,440
- Total dependent packages: 7
- Total dependent repositories: 14
- Total versions: 15
- Total maintainers: 1
cran.r-project.org: runner
Running Operations for Vectors
- Documentation: http://cran.r-project.org/web/packages/runner/runner.pdf
- License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
-
Latest release: 0.4.4
published about 2 years ago
Rankings
Dependent packages count: 6.6%
Stargazers count: 7.0%
Dependent repos count: 7.7%
Average: 10.2%
Downloads: 10.3%
Docker downloads count: 12.6%
Forks count: 17.1%
Maintainers (1)
Last synced:
10 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.0 depends
- Rcpp * imports
- methods * imports
- parallel * imports
- knitr * suggests
- rmarkdown * suggests
- tinytest * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 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.4.1 composite
- actions/checkout v3 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/rhub.yaml
actions
- r-hub/rhub2/actions/rhub-checkout v1 composite
- r-hub/rhub2/actions/rhub-platform-info v1 composite
- r-hub/rhub2/actions/rhub-run-check v1 composite
- r-hub/rhub2/actions/rhub-setup v1 composite
- r-hub/rhub2/actions/rhub-setup-deps v1 composite
- r-hub/rhub2/actions/rhub-setup-r v1 composite
.github/workflows/spellcheck.yaml
actions
- actions/checkout v3 composite
- insightsengineering/r-spellcheck-action v2 composite