fac2dummies {eatGADS}R Documentation

Transform a factor variable to dummy variables.

Description

Convert a factor variable with n levels to n dummy variables.

Usage

fac2dummies(GADSdat, var)

Arguments

GADSdat

A data.frame or GADSdat object.

var

A character vector with the name of the factor variable.

Details

Newly created variables are named as the original variable with the suffix "_a", "_b" and so on. Variable labels are created by using the original variable label (if available) and adding the value label of the corresponding level. All missing codes are forwarded to all dummy variables.

Value

Returns a GADSdat containing the newly computed variables.

Examples

## create an example GADSdat
suppressMessages(gads <- import_DF(iris))

## transform factor variable
gads2 <- fac2dummies(gads, var = "Species")



[Package eatGADS version 1.1.0 Index]