Learn R Programming

treeplyr (version 0.1.10)

forceFactor: Function for checking whether a treedata object contains only factors and for forcing data columns into factor format

Description

This function can be used to check if a treedata object contains factors and, if desired, convert all columns automatically to factors.

Usage

forceFactor(tdObject, return.factor = TRUE)

Arguments

tdObject

A treedata object

return.factor

If TRUE, then a treedata object with all factors will be returned; columns will be forced into factors using factor and any with no repeated elements will be removed.

Value

If return.factor, then an object of class "treedata" with all columns as factors.

Examples

Run this code
# NOT RUN {
data(anolis)
td <- make.treedata(anolis$phy, anolis$dat)
tdforcefactor <- forceFactor(td)
# }

Run the code above in your browser using DataLab