Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

window_fun

Function over grouping variables (window function)


Description

This is faster version of ave. window_fun applies function to every subset of x and return vector of the same length as x.

Usage

window_fun(x, ...)

Arguments

x

A vector

...

Grouping variables all of the same length as x or length 1 and function as last argument.

Value

vector of the same length as x

Examples

window_fun(1:3, mean)  # no grouping -> grand mean

attach(warpbreaks)

window_fun(breaks, wool, mean)
window_fun(breaks, tension, function(x) mean(x, trim = 0.1))

detach(warpbreaks)

expss

Tables, Labels and Some Useful Functions from Spreadsheets and 'SPSS' Statistics

v0.10.7
GPL (>= 2)
Authors
Gregory Demin [aut, cre], Sebastian Jeworutzki [ctb] (<https://orcid.org/0000-0002-2671-5253>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.