as.folderh.foldermtg: Build a hierarchic folder from an object of class foldermtg

View source: R/as.folderh.foldermtg.R

as.folderh.foldermtgR Documentation

Build a hierarchic folder from an object of class foldermtg

Description

Creates an object of class folderh from an object of class foldermtg.

Usage

## S3 method for class 'foldermtg'
as.folderh(x, classes)

Arguments

x

object of class foldermtg.

classes

character vector. Codes of the vertex classes in the returned folderh. These codes are the names of the elements (data frames) of x containing the features on the vertices corresponding to the codes.

These codes must be distinct, and the corresponding classes must have distinct scales (see foldermtg). Otherwise, there is an error.

These codes, except the one with the highest scale, are the keys of the returned folderh.

Details

This function uses folderh.

Value

An object of class folderh. Its elements are the data frames of x containing the features on vertices. Hence, each data frame matches with a class of vertex, and a scale. These data frames are in increasing order of the scale.

A column (factor) is added to the first data frame, containing the identifier of the vertex. Two columns are added to the second data frame:

  1. the first one is a factor which gives, for each vertex, the name of the vertex of the first data frame which is its "parent",

  2. and the second one is also a factor and contains the vertex's identifier.

And so on for the third and following data frames, if relevant.

The column containing the vertex identifiers is redundant with the row names; anyway, it is necessary for folderh.

The key of the relationship between the two first data frame is given by the first column of each of these data frames. If there are more than two data frames, the key of the relationship between the n-th and (n+1)-th data frames (n > 1) is given by the second column of the n$th data frame and the first column of the (n+1)-th data frame.

Author(s)

Rachid Boumaza, Pierre Santagostini, Smail Yousfi, Gilles Hunault, Sabine Demotes-Mainard

See Also

read.mtg: reads a MTG file and creates an object of class "foldermtg". folderh : object of class folderh.

Examples

mtgfile <- system.file("extdata/plant1.mtg", package = "dad")
x <- read.mtg(mtgfile)

# folderh containing the plant ("P") and the stems ("A")
as.folderh(x, classes = c("P", "A"))

# folderh containing the plant ("P"), axes ("A") and phytomers ("M")
as.folderh(x, classes = c("P", "A", "M"))

# folderh containing the plant ("P") and the phytomers ("M")
as.folderh(x, classes = c("P", "M"))

# folderh containing the axes and phytomers
fhPM <- as.folderh(x, classes = c("A", "M"))
# coerce this folderh into a folder, and compute statistics on this folder
fPM <- as.folder(fhPM)
mean(fPM)

dad documentation built on Aug. 30, 2023, 5:06 p.m.