JumpBy: Skip observations

View source: R/small_funs.R

JumpByR Documentation

Skip observations

Description

Skip observations

Usage

JumpBy(x, by, start = 1, fill = NULL)

Arguments

x

vector

by

numeric interval between elements to keep

start

index to start from

fill

how observations are skipped

Details

Mostly useful for labelling only every byth element.

Value

A vector of the same class as x and, if fill is not null, the same length.

See Also

Other utilities: Anomaly(), Mag(), Percentile(), logic

Examples

x <- 1:50
JumpBy(x, 2)   # only odd numbers
JumpBy(x, 2, start = 2)   # only even numbers
JumpBy(x, 2, fill = NA)   # even numbers replaced by NA
JumpBy(x, 2, fill = 6)   # even numbers replaced by 6


metR documentation built on Oct. 14, 2024, 5:09 p.m.