as.data.frame.folderh {dad} | R Documentation |
Hierarchic folder to data frame
Description
Builds a data frame from a folderh
.
Usage
## S3 method for class 'folderh'
as.data.frame(x, row.names = NULL, optional = FALSE, ...,
elt = names(x)[2], key = attr(x, "keys")[1])
Arguments
x |
object of class |
row.names , optional |
for consistency with |
... |
further arguments passed to or from other methods. |
elt |
string. The name of one element of |
key |
string. The name of an element of |
Value
as.data.frame.folderh
returns a data frame whose row names are those of x[[elt]]
(that is x[[j]]
). The data frame contains the values of x[[elt]]
and the corresponding values of the data frames x[[k]]
, these correspondances being defined by the keys of the hierarchic folder.
The column names of the returned data frame are organized in three parts.
The first part consists in the key names
keys[k]
,...,keys[j-1]
.The second part consists in the values of
x[[j]]
.The third part consists in the values of
x[[k]]
except the keykeys[k]
.
See the examples to view these details.
Author(s)
Rachid Boumaza, Pierre Santagostini, Smail Yousfi, Gilles Hunault, Sabine Demotes-Mainard
See Also
folder
, folderh
, as.folder.folderh
.
Examples
# First example: rose flowers
data(roseflowers)
flg <- roseflowers$variety
flx <- roseflowers$flower
flfh <- folderh(flg, "rose", flx)
print(flfh)
fldf <- as.data.frame(flfh)
print(fldf)
# Second example: castles
data(castles.dated)
cag <- castles.dated$periods
cax <- castles.dated$stones
cafh <- folderh(cag, "castle", cax)
print(cafh)
cadf <- as.data.frame(cafh)
print(summary(cadf))
# Third example: leaves (example of a folderh with more than two data frames)
data(roseleaves)
lvr <- roseleaves$rose
lvs <- roseleaves$stem
lvl <- roseleaves$leaf
lvll <- roseleaves$leaflet
lfh <- folderh(lvr, "rose", lvs, "stem", lvl, "leaf", lvll)
lf1 <- as.data.frame(lfh, elt = "lvs", key = "rose")
print(lf1)
lf2 <- as.data.frame(lfh, elt = "lvl", key = "rose")
print(lf2)
lf3 <- as.data.frame(lfh, elt = "lvll", key = "rose")
print(lf3)
lf4 <- as.data.frame(lfh, elt = "lvll", key = "stem")
print(lf4)