reducePast: Reduce a signal with its past values.

Description Usage Arguments Value Examples

View source: R/signal.R

Description

Reduce a signal with its past values.

Usage

1
reducePast(signal, fun, init)

Arguments

signal

A signal.

fun

An accumulator function. Should take two arguments

init

An initial value.

Value

A reactive of the same type as init.

Examples

1
2
3
4
5
6
# Simulate a markov random walk
walk <- reactive({fps(30); sample(c(-1, 0, 1), 1)})
location <- walk %>% reducePast(`+`, 0)

# Eventually:
# reactivePlot(count(walk), location)

hadley/shinySignals documentation built on May 17, 2019, 12:47 p.m.