Converts a categorical variable into several separate binary variables

Description

This function converts a vector (factor) of categorical character strings (integers) into several separate vectors of binary indicators to enable back-compatibility with versions of R2MLwiN prior to 0.8-0.

Usage

1
Untoggle(categrv, name = NULL)

Arguments

categrv

A vector (factor) of categorical character strings (integers).

name

A character string specifying a name of a prefix to be appended the categories when generating dummy variables. If NULL, v__ is used as a prefix.

Value

A matrix containing the generated dummy variables.

Author(s)

Zhang, Z., Charlton, C.M.J., Parker, R.M.A., Leckie, G., and Browne, W.J. (2016) Centre for Multilevel Modelling, University of Bristol.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
library(R2MLwiN)
# NOTE: Assumes MLwiN path is C:/Program Files (x86)/MLwiN v2.30/
# ...so please change relevant line if different
# if using R2MLwiN via WINE, the path may look like 
# options(MLwiN_path='/home/USERNAME/.wine/drive_c/Program Files (x86)/MLwiN v2.30/') 

# Example: tutorial
data(tutorial)
names(tutorial)
tutorial = cbind(tutorial, Untoggle(tutorial$school, 'school'))
names(tutorial)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.