--- spec: openflange.org/pipe/v0.1 id: window-mean version: 0.1.0 title: Window mean (R) description: Mean of the `value` member of each window, one output record per window frame, computed by a streaming R script. license: Apache-2.0 keywords: [r, statistics, window, moving-average, streaming] maturity: experimental scope: window requires: [windows] cardinality: one-to-one deterministic: true inputs: windows: kind: windows description: 'Window frames whose items are records with a numeric `value`.' outputs: means: kind: records description: 'One record per window: {"index", "start", "end", "count", "mean"}.' schema: format: json-schema definition: type: object required: [index, start, end, count, mean] properties: index: {type: integer} start: {type: integer} end: {type: integer} count: {type: integer, minimum: 1} mean: {type: number} implementation: type: script language: r path: window-mean.R permissions: subprocess: true --- # Window mean (R) Implements the [OpenFlange](https://openflange.org/) specification. A **window-scope** pipe: it consumes a `windows` stream (one complete window frame per NDJSON line, as produced by `std:window`) and emits one record per frame. The R script reads one line at a time, so its memory is bounded by the window size, never by the length of the stream. A window containing an item whose `value` is missing or not a number fails the run (`E_RUNTIME`) and names the window. Window framing is a *proposed* feature of the specification. Permissions: `subprocess` (it starts `Rscript --vanilla`).