forceFactor: Function for checking whether a treedata object contains only...

View source: R/treeplyr_functions.R

forceFactorR Documentation

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

data(anolis)
td <- make.treedata(anolis$phy, anolis$dat)
tdforcefactor <- forceFactor(td)

uyedaj/treeplyr documentation built on March 9, 2023, 6:37 p.m.