foldert {dad} | R Documentation |
Folder of data sets among time
Description
Creates an object of class "foldert"
(called foldert below), that is a list of data frames, each of them corresponding to a time of observation. These data sets are on the same variables. They can be on the same individuals or not.
Usage
foldert(x1, x2 = NULL, ..., times = NULL, cols.select = "intersect", rows.select = "")
Arguments
x1 |
data frame (can also be a tibble) or list of data frames.
|
x2 |
data frame. Must be provided if |
... |
optional. One or several data frames when |
times |
Vector of the “times” of observations. It can be either numeric, or an ordered factor or an object of class So there is an order relationship between these times. |
cols.select |
string or character vector. Gives the method used to choose the column names of the data frames of the foldert. This argument can be:
If |
rows.select |
string. Gives the method used to choose the row names of the data frames of the foldert. This argument can be:
|
Details
The class "foldert"
has an attribute attr(,"times")
(the times
argument, when provided) and a logical attributes
attr(,"same.rows")
.
The data frames in the returned foldert all have the same column names. That means that the same variables are observed in every data sets.
If the rows.select
argument is "union"
or "intersect"
, the elements of the returned foldert have the same rows. That means that the same individuals are present in every data sets. This allows to consider the evolution of each individual among time.
If rows.select
is ""
, every rows of this foldert are different, and the row names are made unique by adding the name of the data frame to the row names. In this case, The individuals of the data sets are assumed to be all different. Or, at least, the user does not mind if they are the same or not.
Value
Returns an object of class "foldert"
, that is a list of data frames. The elements of this list are ordered according to time.
Author(s)
Rachid Boumaza, Pierre Santagostini, Smail Yousfi, Gilles Hunault, Sabine Demotes-Mainard
See Also
is.foldert
to test if an object is of class foldert
.
as.foldert.data.frame
: build an object of class foldert
from a data frame.
as.foldert.array
: build an object of class foldert
from a 3d
-array.
Examples
x <- data.frame(xyz = rep(c("A", "B", "C"), each = 2),
xy = letters[1:6],
x1 = rnorm(6),
x2 = rnorm(6, 2, 1),
row.names = paste0("i", 1:6),
stringsAsFactors = TRUE)
y <- data.frame(xyz = c("A", "A", "B", "C"),
xy = c("a", "b", "a", "c"),
y1 = rnorm(4, 4, 2),
row.names = c(paste0("i", c(1, 2, 4, 6))),
stringsAsFactors = TRUE)
z <- data.frame(xyz = c("A", "B", "C"),
z1 = rnorm(3),
row.names = c("i1", "i2", "i5"),
stringsAsFactors = TRUE)
# Columns selected by the user
ftc. <- foldert(x, y, z, cols.select = c("xyz", "x1", "y1", "z1"))
print(ftc.)
# cols.select = "union": all the variables (columns) of each data frame are kept
ftcun <- foldert(x, y, z, cols.select = "union")
print(ftcun)
# cols.select = "intersect": only variables common to all data frames
ftcint <- foldert(x, y, z, cols.select = "intersect")
print(ftcint)
# rows.select = "": the rows of the data frames are unchanged
# and the rownames are made unique
ftr. <- foldert(x, y, z, rows.select = "")
print(ftr.)
# rows.select = "union": all the individuals (rows) of each data frame are kept
ftrun <- foldert(x, y, z, rows.select = "union")
print(ftrun)
# rows.select = "intersect": only individuals common to all data frames
ftrint <- foldert(x, y, z, rows.select = "intersect")
print(ftrint)
# Define the times (times argument)
ftimes <- foldert(x, y, z, times = as.Date(c("2018-03-01", "2018-04-01", "2018-05-01")))
print(ftimes)