Learn R Programming

oak (version 0.2.3)

as.rtree: Conversion to an 'rtree' object

Description

These methods convert an object to an rtree object.

Usage

as.rtree(x, ...)

# S3 method for rtree as.rtree(x, ...)

# S3 method for character as.rtree(x, ...)

# S3 method for data.frame as.rtree(x, ...)

Arguments

x

An object to be converted.

...

Additional parameters (not used).

Value

An rtree object.

Examples

Run this code
# NOT RUN {
## Rooted tree
df = data.frame(x = c("A", "A", "A", "A"), 
                y = c("B", "C", "C", "C"), 
                z = c("D", "E", "E", "F"), 
                stringsAsFactors = FALSE)
                
(as.rtree(df))

## Unrooted tree
df = data.frame(x = c("A", "A", "A", "X"), 
                y = c("B", "C", "C", "Y"), 
                z = c("D", "E", "E", "Z"), 
                stringsAsFactors = FALSE)
                
(as.rtree(df))

# }

Run the code above in your browser using DataLab