folderh | R Documentation |
Creates an object of class folderh
, that is a list of n>1
data frames whose rows are related by (n-1) keys, each key defining a relation "1 to N" between the two adjacent data frames passed as arguments of the function.
folderh(df1, key1, df2, ..., na.rm = TRUE)
df1 |
data frame (can also be a tibble) with at least two columns. It contains a factor (whose name is given by |
key1 |
character string. The name of the factor of the data frames |
df2 |
data frame (or tibble) with at least two columns. It contains a factor column (named by |
... |
optional. One or several supplementary character strings and data frames, ordered as follows: |
na.rm |
logical. If |
The object of class folderh
is a list of n \ge 2
data frames.
If no optional arguments are given via ...
, that is n = 2
, the two data frames of the list
have a column named by the attribute attr(, "keys")
(argument key1
), which is a factor with the same levels.
Each one of these levels occur exactly once in the first data frame of the list.
If some supplementary data frames and supplementary strings key2, df3
, ... are given as optional arguments, n
is the number of data frames given as arguments.
Then, the attribute attr(, "keys")
is a vector of n-1
character strings.
For i = 1, \ldots, N-1
, its i
-th element is the name of a column of the i
-th and (i+1)
-th data frames of the folderh, which are factors with the same levels.
Each one of these levels occur exactly once in the i
-th data frame.
If there are more than two data frames, folderh
computes a folderh with the two last data frames, and then uses the function appendtofolderh
to append each one of the other data frames to the folderh.
Returns an object of class folderh
. Its elements are the data frames passed as arguments, and the attribute attr(, "keys")
contains the character arguments.
Rachid Boumaza, Pierre Santagostini, Smail Yousfi, Gilles Hunault, Sabine Demotes-Mainard
is.folderh
to test if an object is of class folderh
.
folder
for a folder of data frames with no hierarchic relation between them.
as.folder.folderh
(or as.data.frame.folderh
) to build an object of class folder
(or a data frame) from an object of class folderh
,
# First example: rose flowers
data(roseflowers)
df1 <- roseflowers$variety
df2 <- roseflowers$flower
fh1 <- folderh(df1, "rose", df2)
print(fh1)
# Second example
data(roseleaves)
roses <- roseleaves$rose
stems <- roseleaves$stem
leaves <- roseleaves$leaf
leaflets <- roseleaves$leaflet
fh2 <- folderh(roses, "rose", stems, "stem", leaves, "leaf", leaflets)
print(fh2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.