shifter: "Shift" the Values of a Vector Ahead or Behind by a Specified...

Description Usage Arguments Value Author(s) References Examples

View source: R/shifter.R

Description

This function "shifts" the values of a vector by a specified amount. For instance, if you are starting with a vector, "x", where the range of values is between 1 and 10, and you want 10 to be replaced by 9, 9 to be replaced by 8, and so on, with 1 being ultimately replaced by 10, this funciton should be of use.

Usage

1
shifter(x = 1:10, n = 1)

Arguments

x

The range that you are shifting

n

How much of a shift you want

Value

A vector of shifted values

Author(s)

Ananda Mahto

References

http://stackoverflow.com/a/20825012/1270695

Examples

1
2
3
4
5
6
set.seed(1)
X <- sample(10, 20, replace = TRUE)
X

shifter()[X]
shifter(n = -2)[X]

mrdwab/SOfun documentation built on June 20, 2020, 6:15 p.m.