View source: R/utilities_math.R

clumper | R Documentation |

Internal soundgen function.

clumper(s, minLength)

`s` |
a vector (soundgen supplies integers, but |

`minLength` |
an integer or vector of integers indicating the desired length of a segment at each position (can vary with time, e.g., if we are processing pitch_per_gc values) |

`clumper`

makes sure each homogeneous segment in a sequence is at least
minLength long. Called by getIntegerRandomWalk() and getVocalFry(). Algorithm:
go through the sequence once. If a short segment is encountered, it is pooled
with the previous one (i.e., the currently evaluated segment grows until it
is long enough, which may shorten the following segment). Finally, the last
segment is checked separately. This is CRUDE - a smart implementation is
pending!

Returns the original sequence s transformed to homogeneous segments of required length.

s = c(1,3,2,2,2,0,0,4,4,1,1,1,1,1,3,3) soundgen:::clumper(s, 2) soundgen:::clumper(s, 3) soundgen:::clumper(s, seq(1, 3, length.out = length(s))) soundgen:::clumper(c('a','a','a','b','b','c','c','c','a','c'), 4)

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.