Description Usage Arguments Value Note Author(s) Examples

Variability Measures

`by_id`

- Internal function to allow a simple statistic (e.g., SD)
to be calculated individually by an ID variable and returned
either as per ID (i.e., wide form) or for every observation of an
ID (i.e., long form).

`sd_id`

- Calculates the standard deviation of observations by `ID`

.

`rmssd`

- Calculates the root mean square of successive differences (RMSSD).
Note that missing values are removed.

`rmssd_id`

- Calculates the RMSSD by ID.

`rolling_diff`

- Calculates the average rolling difference of the data.
Within each window, the difference between the maximum and minimum value is
computed and these are averaged across all windows. The equation is:

*\frac{∑_{t = 1}^{N - k} max(x_{t}, …, x_{t + k}) - min(x_{t}, …, x_{t + k})}{N - k}*

`rolling_diff_id`

- Calculates the average rolling difference by ID

1 2 3 4 5 6 7 8 9 10 11 |

`x` |
A data vector to operate on. Should be a numeric or integer vector, or coercible to such (e.g., logical). |

`ID` |
an ID variable indicating how to split up the |

`fun` |
The function to calculate by ID |

`long` |
A logical indicating whether to return results in
“long” form (the default) or wide (if |

`window` |
An integer indicating the size of the rolling window.
Must be at least the length of |

`...` |
Additional arguments passed on to |

`by_id`

- A vector the same length as `x`

if `long=TRUE`

, or the length of unique `ID`

s if
`long=FALSE`

.

`sd_id`

- A vector of the standard deviations by ID

`rmssd`

- The RMSSD for the data.

`rmssd_id`

- A vector of the RMSSDs by ID

`rolling_diff`

- The average of the rolling differences between maximum and minimum.

`rolling_diff_id`

- A vector of the average rolling differences by ID

These are a set of functions designed to calculate various measures of variability either on a single data vector, or calculate them by an ID.

Joshua F. Wiley <[email protected]>

1 2 3 4 5 6 7 8 9 | ```
sd_id(mtcars$mpg, mtcars$cyl, long=TRUE)
sd_id(mtcars$mpg, mtcars$cyl, long=FALSE)
rmssd(1:4)
rmssd(c(1, 3, 2, 4))
rmssd_id(mtcars$mpg, mtcars$cyl)
rmssd_id(mtcars$mpg, mtcars$cyl, long=FALSE)
rolling_diff(1:7, window = 4)
rolling_diff(c(1, 4, 3, 4, 5))
rolling_diff_id(mtcars$mpg, mtcars$cyl, window = 3)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.