Learn R Programming

TED (version 1.1.1)

ts2mat: Reshape a vector into a matrix

Description

This function reshapes a vector into a matrix whose row elements are taken from the vector. Orders of elements keep unchanged from the vector.

Usage

ts2mat(x, w)

Arguments

x
a vector or a time series
w
a number specifying number of columns of the matrix

Value

a matrix

Examples

Run this code
x=ts2mat(c(1:(128*20)),128)
dim(x)
x[1,1:20]

Run the code above in your browser using DataLab