Learn R Programming

locits (version 1.7.7)

zeropad: Intersperse zeroes in a vector.

Description

Take a vector of any length and then intersperse zeroes between existing elements (and add a further zero to the end).

Usage

zeropad(x)

Value

A vector whose odd elements are just x and whose even elements are zeroes.

Arguments

x

Vector that you want to intersperse zeros into.

Author

G.P. Nason

Details

Title says it all.

See Also

hwt

Examples

Run this code
#
# Operate on a test set
#
v <- 1:3
zeropad(v)
#[1] 1 0 2 0 3 0

Run the code above in your browser using DataLab