DataFrameStack {gmGeostats} | R Documentation |
Create a data frame stack
Description
Make a stacked data frame, that is, a stack of data.frames representing e.g. repeated measurements, parallel time series, or a stack of multivariate realisation of some random process. If a data frame is analogous to a matrix, a DataFrameStack is analogous to an array. It is highly recommendable to work with named dimensions in stacked data frames.
Usage
DataFrameStack(x, ...)
as.DataFrameStack(x, ...)
## S3 method for class 'data.frame'
DataFrameStack(x, stackDim = 2, dim = NULL, Dimnames = NULL, ...)
## S3 method for class 'data.frame'
as.DataFrameStack(x, stackDim = 2, dim = NULL, Dimnames = NULL, ...)
## S3 method for class 'array'
DataFrameStack(x, stackDim = 2, ...)
## S3 method for class 'array'
as.DataFrameStack(x, stackDim = 2, ...)
## S3 method for class 'list'
DataFrameStack(x, stackDimName = NULL, Dimnames = NULL, ...)
## S3 method for class 'list'
as.DataFrameStack(x, stackDimName = NULL, Dimnames = NULL, ...)
Arguments
x |
object containing the individual data sets, this can be an arra, a list or a data.frame |
... |
further parameters, ignored but necessary for generic functionality |
stackDim |
for "array" and "data.frame" input, which dimension (name or index) identifies the stacking dimension; this is typically the replication, realisation or time slice index |
dim |
for "data.frame" input, how is the data provided to be arranged in slices? |
Dimnames |
for "list" and "data.frame input, which names do you want to give to the resulting array-like structure; note that for input "array" it is necessary that these names are already given to the input array beforehand! |
stackDimName |
for "list" input, which name or index do you want to give to the stacking dimension? |
Value
The data provided reorganised as a DataFrameStack, with several additional attributes.
Functions
-
DataFrameStack
: create a DataFrameStack from an array -
as.DataFrameStack
: create a DataFrameStack from an array -
as.DataFrameStack.data.frame
: create a DataFrameStack from an array -
DataFrameStack.array
: create a DataFrameStack from an array -
as.DataFrameStack.array
: create a DataFrameStack from an array -
DataFrameStack.list
: create a DataFrameStack from a list -
as.DataFrameStack.list
: create a DataFrameStack from an array
See Also
stackDim()
to get or set the stacking dimension;
noStackDim()
to get (not set) the non-stacking dimension;
as.array.DataFrameStack()
and as.list.DataFrameStack()
to
convert the stack to an array or a list;
dimnames.DataFrameStack()
to get the dimension names;
[ā [.DataFrameStackā
] to extract rows of a stack;
getStackElement()
and setStackElement
(same page as getStackElement
)
to extract/modify an
element of the stack; gmApply()
to
apply any function to the stack, typically element-wise;
and swarmPlot()
to combine plot elements for each stack element
into a single plot.
Examples
ll = lapply(1:3, function(i) as.data.frame(matrix(1:10+(i-1)*10, ncol=2)))
dfs = DataFrameStack(ll, stackDimName="rep")
dimnames(dfs)
df = as.data.frame(matrix(1:30, ncol=6))
dfs = DataFrameStack(df, dimnames = list(obs=1:5, vars=c("A","B"), rep=1:3), stackDim = "rep")
dimnames(dfs)
ar = array(1:30, dim = c(5,2,3), dimnames=list(obs=1:5, vars=c("A","B"), rep=1:3))
dfs = DataFrameStack(ar, stackDim="rep")
dimnames(dfs)