dummy {BAT} | R Documentation |

## Dummify variables.

### Description

Convert factor variables to dummy variables.

### Usage

```
dummy(trait, convert = NULL, weight = FALSE)
```

### Arguments

`trait` |
A species x traits matrix or data.frame. |

`convert` |
A vector of column numbers, usually categorical variables, to be converted to dummy variables. |

`weight` |
Indicates whether weights of variables should be returned (TRUE/FALSE) or a vector with weights per variable. |

### Details

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

### Value

A matrix with variables converted or, if weight == TRUE or a vector, a list also with weights.

### Examples

```
trait = data.frame(length = c(2,4,6,3,1), wing = c("A", "B", "A", "A", "B"))
dummy(trait)
dummy(trait, weight = TRUE)
dummy(trait, convert = 2, weight = c(0.9, 0.1))
```

[Package

*BAT*version 2.9.6 Index]