every: Sequence of Values in Regular Increments

View source: R/S03_Utilities.R

everyR Documentation

Sequence of Values in Regular Increments

Description

Extracts a sequence of values from a vector in regular increments.

Usage

every(x, step = 2, start = 1)

every(x, step = 2, start = 1) <- value

Arguments

x

A vector of values.

step

The size of the increment between indices in the sequence.

start

The index at which to start the sequence.

value

A vector of new values to assign to x at the sequence of indices.

Value

A vector of values extracted from x.

Examples

# Extract every other value
# at odd positions
every(1:10)
# Extract every other value
# at even positions
every(1:10, , 2) # Note double commas

# Extract every 3rd value starting
# from 6th position
every(1:12, 3, 6)

# Replace values at even
# positions with 0
x <- 1:10
every(x, , 2) <- 0
x

rettopnivek/arfpam documentation built on Oct. 20, 2024, 7:24 p.m.