Learn R Programming

BAT (version 2.5.1)

dummy: Dummify variables.

Description

Convert factor variables to dummy variables.

Usage

dummy(trait, convert = NULL)

Arguments

trait

a species x traits matrix or data.frame.

convert

a vector of column numbers to be converted to dummy variables.

Value

A matrix with variables converted when needed.

Details

If convert is given the algorithm will convert these column numbers to dummy variables. Otherwise it will convert all columns with characters as values.

Examples

Run this code
# NOT RUN {
trait = data.frame(length = c(2,4,6,3,1), wing = c("A", "B", "A", "A", "B"))
dummy(trait)
dummy(trait, convert = c(1))
# }

Run the code above in your browser using DataLab