mat2df: Convert a matrix to data frame

View source: R/convert.r

mat2dfR Documentation

Convert a matrix to data frame

Description

Convert a matrix (or a set of matrices and vectors) with numeric values to a data frame. If only Y is provided, convert the matrix Y to a dataframe of similar dimensions. If additional matrices and/or vectors are provided, the output will be a 'long-reshaped' dataframe.

Usage

mat2df(Y, ...)

Arguments

Y

A matrix

...

An additional set of matrices and vectors. These matrices have to be of similar dimensions than Y. The vectors have to have a similar amount of values than Y or than the number of rows in Y.

Value

The data frame made of the matrix or the set of inputs. If multiple inputs are provided, the 'long' format data frame will have with two columns + the number of inputs: 'time' and 'id' follow by 'value', 'values.1', 'values.2', etc.

See Also

Other convert: df2mat(), fac2num(), long()

Examples

Y <- df2mat(dfPolicyRate)
df = mat2df(Y)
head(df)

Y <- df2mat(dfPolicyRate)
df = mat2df(Y, dim(Y)[2]:1, Y, 1:dim(Y)[2])
tail(df)


benjaminpeeters/BePe documentation built on July 7, 2022, 5:45 p.m.