Last data update: 2014.03.03

R: Switch between different data formats.
formatFuncyR Documentation

Switch between different data formats.

Description

Datasets can be stored in different formats.

"Format1":

General format for regular and irregular data. One long matrix with curve-ID in first column, curve evaluations in second and time points in third column.

"Format2":

Format for regular data only. Matrix of dimension nr_time x nr_curves.

"Format3":

Format for regular and irregular datasets. List of three matrices, all with same dimension. One evaluation matrix Yin where curves are stored in rows. One matrix of time points Tin. One incidence matrix isobs with entry 1, if curve has evaluation at this time point.

Usage

## S4 method for signature 'list,character'
formatFuncy(data, format="Format1", regTime=NULL)
## S4 method for signature 'matrix,character'
formatFuncy(data, format="Format1", regTime=NULL)

Arguments

data

Data in format "Format1", "Format2" or "Format3".

format

Format to transform data to. One of "Format1" or "Format3".
"Format2" is possible only if dataset in data is regular.

regTime

Optional vector of time points if original data is in "Format2".

Details

Data, especially for irregular time points is often stored in different ways. To switch back and forth between data formats, formatFuncy can be used. For regular datasets in format "Format2", an optional vector of evaluation time points can be given as regTime.

Value

Numeric matrix if format="Format1" or format="Format2". If format="Format3", a list of the three matrices Yin, Tin, isobs and two vectors N and t_all. N stores the number of time points for each curve and t_all is a vector of unique time points (see Arguments).

Author(s)

Christina Yassouridis

Examples

##Generate regular dataset
set.seed(2005)
ds <- sampleFuncy(obsNr=100, k=6, timeNr=20, reg=TRUE)
Data(ds)

##Format dataset to Format1
newdat <-formatFuncy(data=Data(ds), format="Format1")
newdat

##Back to matrix out of Format1
formatFuncy(newdat, format="Format2")

##To Format3
formatFuncy(newdat, format="Format3")

##Generate irregular dataset
set.seed(2005)
ds <- sampleFuncy(obsNr=100, k=5, timeNrMin=5, timeNrMax=10, reg=FALSE)

res <- formatFuncy(Data(ds), format="Format3", reg=FALSE)
res

##Back to Format1
formatFuncy(data=res, format="Format1", reg=FALSE)

Results