shift.sequence {haarfisz}R Documentation

shift.sequence

Description

One of my functions to resolve issues for a similar function that seems to have been forgotten in haarfisz.

Usage

shift.sequence(v, places, dir="right")

Arguments

v

Vector to shift

places

The number of places to shift

dir

Whether the shift should be right or left

Details

This function takes a sequence input and shifts it to the left or right by the specified number of places. This is a circular shift. For example, when shifting to the right, any numbers that drop off are appended circularly to the front, etc.

Value

a shifted output sequence.

Author(s)

Piotr Fryzlewicz

References

Fryzlewicz, P. and Nason, G.P. (2004) A Haar-Fisz algorithm for Poisson intensity estimation. Journal of Computational and Graphical Statistics, 13, 621-638. doi:10.1198/106186004X2697

Examples

#
# Shift 1:10 one place to the right
#
shift.sequence(1:10,1, dir="right")
#  [1] 10  1  2  3  4  5  6  7  8  9

#
# Shift 1:10 twos place to the right
#
shift.sequence(1:10,2, dir="right")
#  [1]  9 10  1  2  3  4  5  6  7  8

#
# Shift 1:10 one place to the left
#
shift.sequence(1:10,1, dir="left")
# [1]  2  3  4  5  6  7  8  9 10  1

[Package haarfisz version 4.5.4 Index]